﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using LibHuman;
using Human.Properties;
using Human.FormBaoCao;
using Human.FormXuLy;

namespace Human
{
    public partial class frmMain2005 : Form
    {
        AccessData mDB = new AccessData();
        private module f_modul;
        Language lan = new Language();
        modify modi;
        private ToolTip m_toolTip = null;
        public string  s_makp = "", _right = "", pass = "",user="";
        bool m_admin = false;
        private DataSet ds,_model,_all_right;
        public string sever_st = "";
        public string user_dn = "", ma = "", s_maquyen,ten_nd="",s_mmyy="",thang="",nam="";
        public DateTime ngay_ht;
       
        public frmMain2005()
        {
            InitializeComponent();
            lan.Read_MainMenu_to_Xml(this.Name.ToString() + "_" + "menuStrip1", menuStrip1);
            lan.Change_mainmenu_to_English(this.Name.ToString() + "_" + "menuStrip1", menuStrip1);
            set_model();
            this.Text = AccessData.Msg;
            this.Update();
            lbNgay.Text = "Ngày giờ: " + ngay_ht;
            sever_st = Settings.Default.SeverName.ToString();
            if (sever_st == "")
            {
                fconfigSyt f = new fconfigSyt();
                f.ShowDialog();
            }
        }

        private void frmMain2005_Load(object sender, EventArgs e)
        {
            frmload fl = new frmload();
            fl.TopMost = true;
            fl.Update();
            fl.Show();
            Application.DoEvents();
            user = mDB.user;
            ngay_ht = DateTime.Now.Date;
            s_mmyy = ngay_ht.ToString("dd/MM/yyyy").Substring(3, 2) + ngay_ht.ToString("dd/MM/yyyy").Substring(8, 2);
            thang = ngay_ht.ToString("dd/MM/yyyy").Substring(3, 2);
            nam = ngay_ht.ToString("dd/MM/yyyy").Substring(6,4);
            //if (Screen.PrimaryScreen.WorkingArea.Width >= 1000)//
            //{
            //    this.BackgroundImage = lbl1024.Image;
            //}
            //else
            //{
            //    this.BackgroundImage = lbl800.Image;
            //}
            this.Update();
            mDB.setStandar();
            ds = mDB.get_data("select * from " + user + ".pwhuman ");
            fl.Close();
            fl.Dispose();
            timer1.Enabled = true;
            frmLogin f = new frmLogin();
            f.ShowDialog();
            ngay_ht = DateTime.Now;
            f.TopMost = true;            
            if (f.ten_nd != "")
            {
                user_dn = f.ten_nd;
                pass = f.pass;
                ma = f.c_d;
                s_maquyen = f.maquyen;
                ten_nd = f.sten;
                s_makp = f.s_makp;
                m_admin = f.m_admin;
                mnuLogout.Text = "Log Off " + ten_nd + "";
                //f_set_right(s_maquyen);
                lbNgaylv.Text = "Nhân viên : " + ten_nd;
            }
            else
                Application.Exit();
        }

        private bool IsLoaded(string frm)
        {
            Form[] afrm = this.MdiChildren;
            foreach (Form f in afrm)
            {
                if (f.Name.Equals(frm)) { f.Activate(); return true; }
            }
            return false;
        }
        public void set_model()
        {
            try
            {
                //_right = mDB.all_right();
                //f_set_right(_right);
            }
            catch
            { }
        }
        private void f_get_menu()
        {
            DataSet dsxml = new DataSet();
            dsxml.Tables.Add();
            DataColumn dc = new DataColumn();
            dc.ColumnName = "loai";
            dc.DataType = Type.GetType("System.String");
            dsxml.Tables[0].Columns.Add(dc);
            dc = new DataColumn();
            dc.ColumnName = "tenloai";
            dc.DataType = Type.GetType("System.String");
            dsxml.Tables[0].Columns.Add(dc);
            dc = new DataColumn();
            dc.ColumnName = "id";
            dc.DataType = Type.GetType("System.String");
            dsxml.Tables[0].Columns.Add(dc);
            dc = new DataColumn();
            dc.ColumnName = "ten";
            dc.DataType = Type.GetType("System.String");
            dsxml.Tables[0].Columns.Add(dc);

            int i = 0;
            string _rr = "";
            foreach (ToolStripItem ait in menuStrip1.Items)
            {
                i++;
                if (ait == menu_D_Cuaso) break;
                if (ait.GetType().ToString() == "System.Windows.Forms.ToolStripMenuItem")
                {
                    ToolStripMenuItem amenu = (ToolStripMenuItem)(ait);
                    _rr = ait.MergeIndex.ToString().PadLeft(5, '0');
                    if (_right.Contains(_rr))
                    {
                        ins_items(dsxml, i.ToString().PadLeft(5, '0'), amenu.Text.Replace("&", ""), _rr, amenu.Text.Replace("&", ""));
                        if (amenu.DropDownItems.Count > 0)
                        {
                            f_Add_Dataset(dsxml, amenu, i);
                        }
                    }
                }
            }
            dsxml.WriteXml("..\\xml\\m_menubar.xml", XmlWriteMode.WriteSchema);
        }

        private void ins_items(DataSet dsxml, string loai, string tenloai, string id, string ten)
        {
            DataRow r = dsxml.Tables[0].NewRow();
            r["loai"] = loai;
            r["tenloai"] = tenloai;
            r["id"] = id;
            r["ten"] = ten;
            dsxml.Tables[0].Rows.Add(r);
        }
        private void f_Add_Dataset(DataSet v_node, ToolStripMenuItem v_item, int id_loai)
        {
            int m_idl = 0;
            string _rr = "";
            m_idl = id_loai;
            foreach (ToolStripItem ait in v_item.DropDownItems)
            {
                if (ait.GetType().ToString() == "System.Windows.Forms.ToolStripMenuItem")
                {
                    ToolStripMenuItem amenu = (ToolStripMenuItem)(ait);
                    _rr = ait.MergeIndex.ToString().PadLeft(5, '0');
                    if (_right.Contains(_rr))
                    {
                        ins_items(v_node, m_idl.ToString().PadLeft(5, '0'), amenu.Text.Replace("&", ""), ait.MergeIndex.ToString().PadLeft(5, '0'), amenu.Text.Replace("&", ""));
                        if (amenu.DropDownItems.Count > 0)
                        {
                            f_Add_Dataset(v_node, amenu, m_idl);
                        }
                    }
                }
            }
        }
        private void commentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form frm = KiemTraTonTai(typeof(module));
            if (frm != null)
                frm.Activate();
            else
            {
                if (ten_nd.Equals("links715501920") && pass.Equals("715501920"))
                {
                    f_modul = new module(s_maquyen,s_mmyy);
                    f_modul.MdiParent = this;
                    f_modul.Show();
                }
            }
        }
        private Form KiemTraTonTai(Type formType)
        {
            foreach (Form f in this.MdiChildren)
            {
                if (f.GetType() == formType)
                    return f;
            }
            return null;
        } 
        private void f_Set_Node(ToolStripMenuItem v_item, string _right_all)
        {
            string _rr = "";
            foreach (ToolStripItem ait in v_item.DropDownItems)
            {
                if (ait.GetType().ToString() == "System.Windows.Forms.ToolStripMenuItem")
                {
                    ToolStripMenuItem amenu = (ToolStripMenuItem)(ait);
                    _rr = amenu.MergeIndex.ToString().PadLeft(5, '0');
                    if (_right.Contains(_rr))
                    {
                        try
                        {
                            amenu.Visible = _right_all.IndexOf(_rr) != -1;
                        }
                        catch
                        {
                            amenu.Visible = false;
                        }
                        if (amenu.DropDownItems.Count > 0)
                        {
                            f_Set_Node(amenu, _right_all);
                        }
                    }
                    else
                        amenu.Visible = false;
                }
            }
        }

        public void f_set_right(string _right_all)
        {
            string _rr = "";
            try
            {
                foreach (ToolStripItem ait in menuStrip1.Items)
                {
                    if (ait == menu_D_Cuaso) break;
                    if (ait.GetType().ToString() == "System.Windows.Forms.ToolStripMenuItem")
                    {
                        ToolStripMenuItem amenu = (ToolStripMenuItem)(ait);
                        _rr = amenu.MergeIndex.ToString().PadLeft(5, '0');
                        if (_right.Contains(_rr))
                        {
                            try
                            {
                                amenu.Visible = _right_all.IndexOf(_rr) != -1;
                            }
                            catch
                            {
                                amenu.Visible = false;
                            }
                            if (amenu.DropDownItems.Count > 0)
                            {
                                f_Set_Node(amenu, _right_all);
                            }
                        }
                        else
                            amenu.Visible = false;
                    }
                }
            }
            catch
            {
            }
            mnuLogout.Enabled = true;
        }
        private void loutToolStripMenuItem_Click(object sender, EventArgs e)
        {            
            frmLogin f = new frmLogin();
            f.ShowDialog();
            if (f.ten_nd != "")
            {
                user_dn = f.ten_nd;
                ma = f.c_d;
                s_maquyen = f.maquyen;
                ten_nd = f.sten;
                s_makp = f.s_makp;
                m_admin = f.m_admin;
                pass = f.pass;
                mnuLogout.Text = "Log Off " + ten_nd + "";
                _right = mDB.all_right();
                f_set_right(s_maquyen);
                lbNgaylv.Text = "Nhân viên : " + ten_nd;                
                ngay_ht = DateTime.Now;
            }
            else
                Application.Exit();
        }        
        private void bcthnsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                DLLBCTonghop.frmQuanlybenhvien af = new DLLBCTonghop.frmQuanlybenhvien("hrs_baocao");
                af.ShowInTaskbar = false;
                af.MdiParent = this;
                af.Show();
            }
            catch
            {
            }
        }
        private void capnhatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sql = "";
            mDB.Execute_data(" alter table " + user + ".chamcong add column ts_ntonhc numeric(8,2) default 0");
            mDB.Execute_data(" alter table " + user + ".lichlv rename column tinhngay to sogio");
            mDB.Execute_data(" alter table " + user + ".lichlv alter column sogio type numeric(10,2)");
            mDB.Execute_data(" alter table " + user + ".lichlv alter column sogio set default 0");
            //chinh sua bang nv_tangcuong
            mDB.Execute_data("alter table " + user + ".nv_tangcuong add column tungay timestamp");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong add column denngay timestamp");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong add column madv_tc varchar(3)");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong add column ghichu text");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong drop column songay1 cascade");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong drop column hs_ud_moi1 cascade");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong drop column mmyy cascade");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong drop column tenbp cascade");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong add column mmyy varchar(4)");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong drop CONSTRAINT nv_tangcuong_pkey;");
            mDB.Execute_data("alter table " + user + ".nv_tangcuong add constraint nv_tangcuong_pkey primary key (manv, tungay) ");
            //
            mDB.Execute_data("alter table " + user + ".mahd add column sothang numeric(5) default 0");
            mDB.Execute_data("alter table " + user + ".dm_quydinhchamcong add column manhom varchar(2)");
            mDB.Execute_data("alter table " + user + ".bophan add column khuvuc varchar(2)");
            mDB.Execute_data("alter table " + user + ".dmngayle add column loai numeric(1,0) default 0");
            mDB.Execute_data("alter table " + user + ".dmngayle add column mmyy varchar(4)");
            mDB.Execute_data("alter table " + user + ".lichlv add column manhom varchar(2)");
            mDB.Execute_data("alter table " + user + ".phepnam add column ts_ngayton numeric(3,1) default 0");
            // them cot so tien hop dong 
            mDB.Execute_data(" alter table " + user + ".hopdong add column lhd_bantg varchar(2);");
            mDB.Execute_data(" alter table " + user + ".hopdong add column st_bantg numeric(15,2) default 0;");
            mDB.Execute_data(" alter table " + user + ".hopdong add column luong_sp numeric(1) default 0;");
            mDB.Execute_data(" alter table " + user + ".hopdong add column sotien_hd numeric(10,2) default 0;");
            mDB.Execute_data(" alter table " + user + ".hopdong add column thuongkhac numeric(10,2) default 0;");
            mDB.Execute_data(" alter table " + user + ".hopdong add column ten_nd text");
            mDB.Execute_data(" alter table " + user + ".hopdong add column ngayud timestamp");
            mDB.Execute_data(" alter table " + user + ".mahd add column stt numeric(3,0) default 0;");
            mDB.Execute_data(" alter table " + user + ".hopdong add column pc_tdt numeric(12,2) default 0");
            mDB.Execute_data(" alter table " + user + ".hopdong add column tongluong numeric(15,2) default 0");
            mDB.Execute_data(" alter table " + user + ".hopdong add column ngaygiulhd timestamp");
            mDB.Execute_data(" alter table " + user + ".hopdong alter column bhtn type numeric");
            mDB.Execute_data(" alter table " + user + ".hopdong rename column congtacphi to pc_khac");
            mDB.Execute_data(" alter table " + user + ".hopdong alter column pc_khac type numeric(12,2)");
            mDB.Execute_data(" alter table " + user + ".hopdong alter column pc_khac set default 0");
            mDB.Execute_data(" alter table " + user + ".hopdong rename column hs_dt1 to pc_ta");
            mDB.Execute_data(" alter table " + user + ".hopdong alter column pc_ta type numeric(12,2)");
            mDB.Execute_data(" alter table " + user + ".hopdong alter column pc_ta set default 0");
            mDB.Execute_data(" alter table " + user + ".hopdong rename column thuongkhac to pc_tx");
            mDB.Execute_data(" alter table " + user + ".hopdong alter column pc_tx type numeric(12,2)");
            mDB.Execute_data(" alter table " + user + ".hopdong alter column pc_tx set default 0");
            // them cột đánh giá can bộ
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg1 varchar(5)  DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg2 varchar(5)  DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg3 varchar(5)  DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg4 varchar(5)  DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg5 varchar(5)  DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg6 varchar(5)  DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg7 varchar(5)   DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg8 varchar(5)   DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg9 varchar(5)   DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg10 varchar(5)  DEFAULT ''; ");
            mDB.Execute_data("alter table  " + user + ".hopdong  add  dg11 varchar(5)  DEFAULT ''; ");
            //the_cdoan
            mDB.Execute_data("alter table  " + user + ".hopdong  alter column the_cdoan type varchar(20) ;");
            mDB.Execute_data("alter table  " + user + ".hopdong  alter column thedoan type varchar(20) ;");
            mDB.Execute_data("alter table  " + user + ".hopdong  alter column thedang type varchar(20) ;");
            //            chi_bo
            mDB.Execute_data("alter table  " + user + ".hopdong  alter column chi_bo type varchar(20) ;");
            mDB.Execute_data("alter table  " + user + ".hopdong  alter column todoan type varchar(20) ;");
            sql = " alter table " + user + ".hopdong add ld_nghiviec varchar(2)";
            mDB.Execute_data(sql);            //
            sql = "alter table " + user + ".hopdong add tvtungay timestamp; ";
            mDB.Execute_data(sql);
            sql = "alter table " + user + ".hopdong add tvdenngay timestamp;";
            mDB.Execute_data(sql);

            sql = " CREATE TABLE "+user+".loaihd_bantg";
            sql += " (";
            sql += " ma varchar(2) NOT NULL,";
            sql += " ten text,";
            sql += " CONSTRAINT loaihd_bantg_pkey PRIMARY KEY (ma)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE "+user+".loaihd_bantg OWNER TO medisoft;";
            mDB.Execute_data(sql);
            mDB.Execute_data("insert into "+user+".loaihd_bantg(ma,ten) values('01','Giờ')");
            mDB.Execute_data("insert into " + user + ".loaihd_bantg(ma,ten) values('02','Buổi')");
            mDB.Execute_data("insert into " + user + ".loaihd_bantg(ma,ten) values('03','Ngày')");
            mDB.Execute_data("insert into " + user + ".loaihd_bantg(ma,ten) values('04','Đêm')");
            mDB.Execute_data("insert into " + user + ".loaihd_bantg(ma,ten) values('05','Tuần')");
            mDB.Execute_data("insert into " + user + ".loaihd_bantg(ma,ten) values('06','Ca bệnh')");
            //them bang ty le thue thu nha ca nhan
            sql = " CREATE TABLE " + user + ".tyle_ttncn (";
            sql += " id numeric(2) NOT NULL DEFAULT 0,";
            sql += " gh_duoi numeric(10,2) DEFAULT 0,";
            sql += " gh_tren numeric(10,2) DEFAULT 0,";
            sql += " tyle_thue numeric(5,2) DEFAULT 0,";
            sql += " mmyy varchar(4) NOT NULL,";
            sql += " CONSTRAINT tyle_ttncn_pkey PRIMARY KEY (id, mmyy)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE " + user + ".tyle_ttncn OWNER TO medisoft;";
            mDB.Execute_data(sql);
            //them bang danh sach nhan vien nghi thai san
            sql = " CREATE TABLE "+user+".dsnv_nghithaisan (";
            sql += " manv varchar(5) NOT NULL,tungay timestamp NOT NULL,";
            sql += " denngay timestamp,sn_nghiduong numeric(5,1) DEFAULT 0,";
            sql += " tl_huongpc numeric(5,2) DEFAULT 0,ghichu text,";
            sql += " CONSTRAINT dsnv_nghithaisan_pkey PRIMARY KEY (manv, tungay)";
            sql += " ) WITHOUT OIDS;";
            sql += " ALTER TABLE "+user+".dsnv_nghithaisan OWNER TO medisoft;";
            mDB.Execute_data(sql);
            //them bang heso. luu thong so he thong.
            sql = " CREATE TABLE "+user+".heso  (";
            sql += " mmyy varchar(4) NOT NULL,mmltt numeric(10,2) DEFAULT 0,";
            sql += " gbd_ccchieu varchar(5),cccuoituan numeric(1) DEFAULT 0,cc_ngaycn numeric(1) DEFAULT 0,";
            sql += " ccthuongquy numeric(1) DEFAULT 0,cctructc numeric(1) DEFAULT 0,";
            sql += " khoadl numeric(1) DEFAULT 0,nhapmacc numeric(1) DEFAULT 0,";
            sql += " thcctudong numeric(1) DEFAULT 0,sd_ccngayt7 numeric(1) DEFAULT 0,";
            sql += " sd_tgsomtre numeric(1) DEFAULT 0,cctc_taikhoa numeric(1) DEFAULT 0,";
            sql += " tn_thcc numeric(2) DEFAULT 0,dn_thcc numeric(2) DEFAULT 0,";
            sql += " vantay numeric(1) DEFAULT 0,";  
            sql += " mltt numeric(10,2) DEFAULT 0,ngachdn numeric(1) DEFAULT 0,";
            sql += " hsdst_abc numeric(1) DEFAULT 0,stpc_abc numeric(12,2) DEFAULT 0,";
            sql += " h_abc varchar(2) DEFAULT '00',h_phepthem varchar(2) DEFAULT '00',";
            sql += " h_tt varchar(2) DEFAULT '00',h_ng varchar(2) DEFAULT '00',";
            sql += " h_tc varchar(2) DEFAULT '00',h_tq varchar(2) DEFAULT '00',";
            sql += " khoadl_phep numeric(2) DEFAULT 1,pc_tienan numeric(10,2) DEFAULT 0,";
            sql += " pc_tacatruc numeric(10,2) DEFAULT 0,lg_luutruhs numeric(10,2) DEFAULT 0,";
            sql += " luonghd numeric(1) DEFAULT 0,hd_bantg numeric(1) DEFAULT 0,";
            sql += " luong_sp numeric(1) DEFAULT 0,h_hsdt varchar(5) DEFAULT '00000',";
            sql += " h_hsvk varchar(5) default '00000',h_hscv varchar(5) DEFAULT '00000',h_hsdb varchar(5) DEFAULT '00000',";
            sql += " h_hsdh varchar(5) DEFAULT '00000',h_hskv varchar(5) DEFAULT '00000',";
            sql += " h_hsld varchar(5) DEFAULT '00000',h_hsth varchar(5) DEFAULT '00000',";
            sql += " h_hstn varchar(5) DEFAULT '00000',h_hsud varchar(5) DEFAULT '00000',";
            sql += " h_hskh varchar(5) DEFAULT '00000',h_hsta varchar(5) DEFAULT '00000',";
            sql += " h_hstx varchar(5) DEFAULT '00000',h_hstdt varchar(5) DEFAULT '00000',mtietkiem_hs numeric(10,2) DEFAULT 0,";
            sql += " mltt_phucap numeric(10,2) DEFAULT 0,lamviec numeric(3,1) DEFAULT 0,";
            sql += " snlvthucte numeric(3,1) DEFAULT 0,mbhxh_hs numeric(10,3) DEFAULT 0,";
            sql += " mbhyt_hs numeric(10,3) DEFAULT 0,mbhtn_hs numeric(10,3) DEFAULT 0,";            
            sql += " sbhxh_hs numeric(10,3) DEFAULT 0,sbhyt_hs numeric(10,3) DEFAULT 0,";
            sql += " sbhtn_hs numeric(10,3) DEFAULT 0,";
            sql += " gbdng_n varchar(5),gbdng_d varchar(5),gktng_n varchar(5),gktng_d varchar(5),";
            sql += " mcaba_hs numeric(10,2) DEFAULT 0,";
            sql += " mcn_hs numeric(10,2) DEFAULT 0,mletet_hs numeric(10,2) DEFAULT 0,";
            sql += " pcngnt_d numeric(10,2) DEFAULT 0,pcngcn_d numeric(10,2) DEFAULT 0,";
            sql += " pcnglt_d numeric(10,2) DEFAULT 0,hs1 numeric(10,2) DEFAULT 0,";
            sql += " hs2 numeric(10,2) DEFAULT 0,hs3 numeric(10,2) DEFAULT 0,";
            sql += " hs4 numeric(10,2) DEFAULT 0,ma numeric(10,2) DEFAULT 0,";
            sql += " mb numeric(10,2) DEFAULT 0,mc numeric(10,2) DEFAULT 0,";
            sql += " thuonga numeric(10,2) DEFAULT 0,thuongb numeric(10,2) DEFAULT 0,";
            sql += " thuongc numeric(10,2) DEFAULT 0,pctt numeric(10,2) DEFAULT 0,";
            sql += " pctt1 numeric(10,2) DEFAULT 0,pctt2 numeric(10,2) DEFAULT 0,";
            sql += " hpctt numeric(10,2) DEFAULT 0,hpctt1 numeric(10,2) DEFAULT 0,";
            sql += " hpctt2 numeric(10,2) DEFAULT 0,mom_hs numeric(10,2) DEFAULT 0,";
            sql += " lg_tapsu numeric(10,2) DEFAULT 0,lg_dihoc numeric(10,2) DEFAULT 0,";
            sql += " mkpcd_hs numeric(10,2) DEFAULT 0,lanccvt numeric(2) DEFAULT 0,";
            sql += " pctq_nt numeric(10,2) DEFAULT 0,pctq_cn numeric(10,2) DEFAULT 0,";
            sql += " pctq_lt numeric(10,2) DEFAULT 0,pctc_nt numeric(10,2) DEFAULT 0,";
            sql += " pctc_cn numeric(10,2) DEFAULT 0,pctc_lt numeric(10,2) DEFAULT 0,";
            sql += " hpctc_nt numeric(10,2) DEFAULT 0,hpctc_cn numeric(10,2) DEFAULT 0,";
            sql += " hpctc_lt numeric(10,2) DEFAULT 0,";
            sql += " CONSTRAINT heso_pkey PRIMARY KEY (mmyy)";
            sql += " ) WITHOUT OIDS; ALTER TABLE "+user+".heso OWNER TO medisoft;";
            mDB.Execute_data(sql);
            //tao bang he so bao hiem
            sql = " CREATE TABLE "+user+".heso_bh (";
            sql += " loaibh varchar(4) NOT NULL,loaihd varchar(2) NOT NULL,";
            sql += " hs_cv bool DEFAULT false,hs_vk bool DEFAULT false,";
            sql += " hs_kv bool DEFAULT false,hs_tn bool DEFAULT false,";
            sql += " hs_dh bool DEFAULT false,luongkhoan bool DEFAULT false,";
            sql += " hs_lc bool DEFAULT false,mmyy varchar(4) NOT NULL,";
            sql += " CONSTRAINT heso_bh_pkey PRIMARY KEY (loaibh, loaihd, mmyy)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE "+user+".heso_bh OWNER TO medisoft;";
            mDB.Execute_data(sql);
            // them bang heso_nv. nhap thong tin he so phu cap cua nhan vien theo tung thang
            sql = " CREATE TABLE "+user+".heso_nv ( ";
            sql += " manv varchar(5) NOT NULL,madv varchar(3) NOT NULL,";
            sql += " mmyy varchar(4) NOT NULL,bhxh numeric(1) DEFAULT 0,";
            sql += " bhyt numeric(1) DEFAULT 0,bhtn numeric(1) DEFAULT 0,kpcd numeric(1) DEFAULT 0,";
            sql += " h_hsbdhv varchar(4) DEFAULT 0,h_hslc numeric(10,2) DEFAULT 0,";
            sql += " h_hscv numeric(10,2) DEFAULT 0,h_hsvk numeric(10,2) DEFAULT 0,";  
            sql += " h_hstn numeric(10,2) DEFAULT 0,h_hskv numeric(10,2) DEFAULT 0,";
            sql += " h_hsdh numeric(10,2) DEFAULT 0,h_hsdb numeric(10,2) DEFAULT 0,h_hsdt numeric(10,2) DEFAULT 0,";
            sql += " h_hsld numeric(10,2) DEFAULT 0,h_hsth numeric(10,2) DEFAULT 0,";
            sql += " h_hsud numeric(10,2) DEFAULT 0,h_pcta numeric(12,2) DEFAULT 0,";
            sql += " h_pctx numeric(12,2) DEFAULT 0,h_pctdt numeric(12,2) DEFAULT 0,";
            sql += " h_pckh numeric(12,2) DEFAULT 0,h_tongluong numeric(15,2) DEFAULT 0,";
            sql += " h_tonghs numeric(10,2) DEFAULT 0,h_sotienhd numeric(10,2) DEFAULT 0,";
            sql += " h_lhdbantg varchar(2),h_stbantg numeric(15,2) DEFAULT 0,";
            sql += " h_luongsp numeric(1) DEFAULT 0,loaihd varchar(2),";
            sql += " thuviec numeric(1) DEFAULT 0,dihoc numeric(1) DEFAULT 0,";
            sql += " luutruhs numeric(1) DEFAULT 0,ghichu text,";
            sql += " CONSTRAINT heso_nv_pkey PRIMARY KEY (manv, madv, mmyy)";
            sql += " ) WITHOUT OIDS;";
            sql += " ALTER TABLE "+user+".heso_nv OWNER TO medisoft;";
            mDB.Execute_data(sql);
            //tao bang th_chamcong. tong hop tat ca du lieu cham cong cua nhan vien de tinh luong
            sql = " CREATE TABLE "+user+".th_chamcong (";
            sql += " manv varchar(5) NOT NULL,madv varchar(3) NOT NULL,";
            sql += " mmyy varchar(4) NOT NULL,sn_cong numeric(5,2) DEFAULT 0,";
            sql += " nghi_om numeric(5,2) DEFAULT 0,nghi_conom numeric(5,2) DEFAULT 0,";
            sql += " nghi_ad numeric(5,2) DEFAULT 0,nghi_nb numeric(5,2) DEFAULT 0,";  
            sql += " nghi_pn numeric(5,2) DEFAULT 0,nghi_ts numeric(5,2) DEFAULT 0,";  
            sql += " nghi_kt numeric(5,2) DEFAULT 0,nghi_td numeric(5,2) DEFAULT 0,";  
            sql += " nghi_ho numeric(5,2) DEFAULT 0,nghi_ct numeric(5,2) DEFAULT 0,"; 
            sql += " nghi_ld numeric(5,2) DEFAULT 0,nghi_dh numeric(5,2) DEFAULT 0,";
            sql += " nghi_ot numeric(5,2) DEFAULT 0,nghi_kl numeric(5,2) DEFAULT 0,";  
            sql += " nghi_kh numeric(5,2) DEFAULT 0,nghi_bl numeric(5,2) DEFAULT 0,";
            sql += " nghi_le numeric(5,2) DEFAULT 0,nghi_bu numeric(5,2) DEFAULT 0,";
            sql += " ts_coluong numeric(5,2) DEFAULT 0,ts_kluong numeric(5,2) DEFAULT 0,";  
            sql += " ts_bhtra numeric(5,2) DEFAULT 0,ts_khac numeric(5,2) DEFAULT 0,";
            sql += " ts_ngaycong numeric(10,2) DEFAULT 0,ts_ngaytru numeric(10,2) DEFAULT 0,";
            sql += " ts_giocong numeric(10,2) DEFAULT 0,";
            sql += " tt_ngaythuong numeric(5,2) DEFAULT 0,tt_chunhat numeric(5,2) DEFAULT 0,";
            sql += " tt_letet numeric(5,2) DEFAULT 0,htt_ngaythuong numeric(5,2) DEFAULT 0,";  
            sql += " htt_chunhat numeric(5,2) DEFAULT 0,htt_letet numeric(5,2) DEFAULT 0,";
            sql += " sntru_tt numeric(5,2) DEFAULT 0,sn_tructon numeric(5,2) DEFAULT 0,";//so ngay tru thuong truc
            sql += " nng_ngaythuong numeric(5,2) DEFAULT 0,nng_chunhat numeric(5,2) DEFAULT 0,";  
            sql += " nng_letet numeric(5,2) DEFAULT 0,dng_ngaythuong numeric(5,2) DEFAULT 0,";  
            sql += " dng_chunhat numeric(5,2) DEFAULT 0,dng_letet numeric(5,2) DEFAULT 0,";  
            sql += " tq_ngaythuong numeric(5,2) DEFAULT 0,tq_chunhat numeric(5,2) DEFAULT 0,";  
            sql += " tq_letet numeric(5,2) DEFAULT 0,tc_ngaythuong numeric(5,2) DEFAULT 0,";  
            sql += " tc_chunhat numeric(5,2) DEFAULT 0,tc_letet numeric(5,2) DEFAULT 0,";  
            sql += " htc_ngaythuong numeric(5,2) DEFAULT 0,htc_chunhat numeric(5,2) DEFAULT 0,";
            sql += " htc_letet numeric(5,2) DEFAULT 0,";
            sql += " sntru_tc numeric(5,2) DEFAULT 0,";
            sql += " xl_abc varchar(1),l1_c numeric(5,2) DEFAULT 0,";  
            sql += " l1_bs numeric(5,2) DEFAULT 0,l1_p1 numeric(5,2) DEFAULT 0,";  
            sql += " l1_p2 numeric(5,2) DEFAULT 0,l1_k numeric(5,2) DEFAULT 0,";  
            sql += " l1_dc numeric(5,2) DEFAULT 0,l1_gv numeric(5,2) DEFAULT 0,";  
            sql += " l2_c numeric(5,2) DEFAULT 0,l2_bs numeric(5,2) DEFAULT 0,";  
            sql += " l2_p1 numeric(5,2) DEFAULT 0,l2_p2 numeric(5,2) DEFAULT 0,";
            sql += " l2_k numeric(5,2) DEFAULT 0,l2_dc numeric(5,2) DEFAULT 0,";  
            sql += " l2_gv numeric(5,2) DEFAULT 0,l3_c numeric(5,2) DEFAULT 0,";  
            sql += " l3_bs numeric(5,2) DEFAULT 0,l3_p1 numeric(5,2) DEFAULT 0,";  
            sql += " l3_p2 numeric(5,2) DEFAULT 0,l3_k numeric(5,2) DEFAULT 0,";  
            sql += " l3_dc numeric(5,2) DEFAULT 0,l3_gv numeric(5,2) DEFAULT 0,";  
            sql += " db_c numeric(5,2) DEFAULT 0,db_bs numeric(5,2) DEFAULT 0,";  
            sql += " db_p1 numeric(5,2) DEFAULT 0,db_p2 numeric(5,2) DEFAULT 0,";  
            sql += " db_k numeric(5,2) DEFAULT 0,db_dc numeric(5,2) DEFAULT 0,";  
            sql += " db_gv numeric(5,2) DEFAULT 0,tl1_c numeric(5,2) DEFAULT 0,";  
            sql += " tl1_bs numeric(5,2) DEFAULT 0,tl1_p1 numeric(5,2) DEFAULT 0,";  
            sql += " tl1_p2 numeric(5,2) DEFAULT 0,tl1_k numeric(5,2) DEFAULT 0,";
            sql += " tl1_dc numeric(5,2) DEFAULT 0,tl1_gv numeric(5,2) DEFAULT 0,";  
            sql += " tl2_c numeric(5,2) DEFAULT 0,tl2_bs numeric(5,2) DEFAULT 0,";  
            sql += " tl2_p1 numeric(5,2) DEFAULT 0,tl2_p2 numeric(5,2) DEFAULT 0,";  
            sql += " tl2_k numeric(5,2) DEFAULT 0,tl2_dc numeric(5,2) DEFAULT 0,";
            sql += " tl2_gv numeric(5,2) DEFAULT 0,tl3_c numeric(5,2) DEFAULT 0,";  
            sql += " tl3_bs numeric(5,2) DEFAULT 0,tl3_p1 numeric(5,2) DEFAULT 0,";  
            sql += " tl3_p2 numeric(5,2) DEFAULT 0,tl3_k numeric(5,2) DEFAULT 0,";  
            sql += " tl3_dc numeric(5,2) DEFAULT 0,tl3_gv numeric(5,2) DEFAULT 0,";  
            sql += " tdb_c numeric(5,2) DEFAULT 0,tdb_bs numeric(5,2) DEFAULT 0,";  
            sql += " tdb_p1 numeric(5,2) DEFAULT 0,tdb_p2 numeric(5,2) DEFAULT 0,";
            sql += " tdb_k numeric(5,2) DEFAULT 0,tdb_dc numeric(5,2) DEFAULT 0,";  
            sql += " tdb_gv numeric(5,2) DEFAULT 0,";  
            sql += " CONSTRAINT th_chamcong_pkey PRIMARY KEY (manv, madv, mmyy) )";  
            sql += " WITHOUT OIDS;";  
            sql += " ALTER TABLE "+user+".th_chamcong OWNER TO medisoft;";
            mDB.Execute_data(sql);
            //tao bang boiduong_pttt. cap nhat thong tin tien phu cap phau thuat thu thuat
            sql = " CREATE TABLE " + user + ".boiduong_pttt ( ";
            sql += " pttt text NOT NULL,loai varchar(10) NOT NULL,tenloai text,";
            sql += " ptv numeric(10,2) DEFAULT 0,phu1 numeric(10,2) DEFAULT 0,";
            sql += " phu2 numeric(10,2) DEFAULT 0,bsgayme numeric(10,2) DEFAULT 0,";
            sql += " ktvgayme numeric(10,2) DEFAULT 0,hoisuc numeric(10,2) DEFAULT 0,";
            sql += " dungcu numeric(10,2) DEFAULT 0,mmyy varchar(4) NOT NULL,";
            sql += " giupviec numeric(10,2) DEFAULT 0,";
            sql += " CONSTRAINT pk_boiduong_pttt PRIMARY KEY (pttt, loai, mmyy) ";
            sql += " ) WITHOUT OIDS;";
            sql += " ALTER TABLE " + user + ".boiduong_pttt OWNER TO medisoft;";
            mDB.Execute_data(sql);              
            //them cot id vao bang xuat canh
            mDB.Execute_data("alter table " + user + ".xuatcanh add column id numeric(10,0) default 0;");
            //
            //them bang dmchibo
            sql = "CREATE TABLE " + user + ".dmchibo (ma varchar(3) NOT NULL,ten text,nhom varchar(1),stt numeric(3) default 0,  CONSTRAINT pk_dmchibo PRIMARY KEY (ma)) WITH OIDS;";
            mDB.Execute_data(sql);
            //them bang dmchucvudang
            sql = "CREATE TABLE " + user + ".dmchucvudang (ma varchar(3) NOT NULL,ten text,nhom varchar(1),hs_pc numeric(10,2),stt numeric(3),  CONSTRAINT pk_dmchucvudang PRIMARY KEY (ma)) WITH OIDS;";
            mDB.Execute_data(sql);
            //
            mDB.Execute_data("alter table " + user + ".thaydoi_bluong add column ghichu text;");
            mDB.Execute_data("alter table " + user + ".thaydoi_phucap add column ghichu text;");
            mDB.Execute_data("alter table " + user + ".thaydoi_bluong add column loainhap numeric(1,0) default 0;");
            mDB.Execute_data("alter table " + user + ".thaydoi_bluong add column mltt numeric(10,2) default 0;");
            //them field cho bang thaydoi_bluong va thaydoi_phucap
            mDB.Execute_data("alter table nhansu.thaydoi_bluong add column madv varchar(3)");
            mDB.Execute_data("alter table nhansu.thaydoi_bluong add column macv varchar(3)");
            mDB.Execute_data("alter table nhansu.thaydoi_phucap add column madv varchar(3)");
            mDB.Execute_data("alter table nhansu.thaydoi_phucap add column macv varchar(3)");
            mDB.Execute_data("alter table " + user + ".thaydoi_phucap add column loainhap numeric(1,0) default 0;");
            mDB.Execute_data("alter table " + user + ".thaydoi_phucap add column mltt numeric(10,2) default 0;");
            // 24/11 sua lai khoa chinh cho bang khenthuog
            mDB.Execute_data(" alter table " + user + ".khenthuong add column giaykhen bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong add column bangkhen bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong add column bo_kt bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong add column cp_kt bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong add column cstd_ct bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong add column cstd_tq bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong add column hc_h1 bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong add column hc_h2 bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong add column hc_h3 bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong drop constraint khenthuong_pkey");
            mDB.Execute_data(" alter table " + user + ".khenthuong add primary key(manv,nam)");
            //cap nhat bang khenthuong_dv
            mDB.Execute_data(" alter table " + user + ".khenthuong_dv add column cstd_xs bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong_dv add column hc_h1 bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong_dv add column hc_h2 bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong_dv add column hc_h3 bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong_dv add column bo_kt bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong_dv add column cp_kt bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong_dv add column cbo_kt bool DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".khenthuong_dv add column ccp_kt bool DEFAULT false");

            sql = "CREATE TABLE " + user + ".nam ( yyyy varchar(4) NOT NULL,  CONSTRAINT pk_nam PRIMARY KEY (yyyy))";
            mDB.Execute_data(sql);
            sql = "alter table " + user + ".phepnam add nam varchar(4) default ''";
            mDB.Execute_data(sql);
            sql = "alter table " + user + ".phepnam add ts_ngayton numeric(3,1) default 0";
            mDB.Execute_data(sql);

            sql = "alter table " + user + ".dmlydo add thoiviec int default 0;";
            mDB.Execute_data(sql);
            sql = "alter table " + user + ".dmcd add nhombc varchar(2) default '';";
            mDB.Execute_data(sql);
            //
            sql = " CREATE TABLE " + user + ".dmlydo_phep (";
            sql += " ma varchar(2) NOT NULL,";
            sql += " ten text,";
            sql += " nhombc varchar(2),";
            sql += " stt numeric(3) DEFAULT 0,";
            sql += " kihieu_phep varchar(3),";
            sql += " CONSTRAINT pk_dmlydo_phep PRIMARY KEY (ma)) WITH OIDS; ";
            sql += " ALTER TABLE " + user + ".dmlydo_phep OWNER TO medisoft;";
            mDB.Execute_data(sql);
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('X','Lương thời gian','CL',1,'X')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('X2','Lương thời gian nửa ngày','CL',0,'X2')");
            mDB.Execute_data(" insert into "+user+".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('NB','Nghỉ bù','CL',2,'NB')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('B2','Nghỉ bù nửa ngày','CL',3,'B2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('PN','Phép năm','CL',4,'PN')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('P2','Phép năm nửa ngày','CL',5,'P2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('OM','Nghỉ ốm','BH',6,'OM')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('O2','Nghỉ ốm nửa ngày','BH',7,'O2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('CO','Nghỉ trông con ốm','BH',8,'CO')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('C2','Nghỉ trông con ốm nửa ngày','BH',9,'C2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('TS','Nghỉ thai sản','BH',10,'TS')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('S2','Nghỉ thai sản nửa ngày','BH',11,'S2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('KT','Nghỉ đi khám thai','BH',12,'KT')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('M2','Nghỉ đi khám thai nửa ngày','BH',13,'M2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('DH','Nghỉ đi học','CL',14,'DH')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('D2','Nghỉ đi học nửa ngày','CL',15,'D2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('TD','Nghỉ tai nạn lao động','BH',16,'TD')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('N2','Nghỉ tai nạn lao động nửa ngày','BH',17,'N2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('HO','Nghỉ đi họp','CL',18,'HO')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('H2','Nghỉ đi họp nửa ngày','CL',19,'H2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('LD','Nghỉ lao động nghĩa vụ','CL',20,'LD')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('L2','Nghỉ lao động nghĩa vụ nửa ngày','CL',21,'L2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('CT','Nghỉ đi công tác','CL',22,'CT')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('T2','Nghỉ đi công tác nửa ngày','CL',23,'T2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('OT','Nghỉ ôn thi','CL',24,'OT')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('Z2','Nghỉ ông thi nửa ngày','CL',25,'Z2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('AD','Nghỉ an dưỡng','CL',26,'AD')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('A2','Nghỉ an dưỡng nửa ngày','CL',27,'A2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('KL','Nghỉ không lương','KL',28,'KL')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('K2','Nghỉ không lương nửa ngày','KL',29,'K2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('KH','Nghỉ khác','KH',30,'KH')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('V2','Nghỉ khác nửa ngày','KH',31,'V2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('CD','Lý do chính đáng','CL',32,'CD')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('KD','Không có lý do chính đáng','KL',33,'KD')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('BL','Nghỉ bù ngày lễ','CL',34,'BL')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('F2','Nghỉ bù ngày lễ nửa ngày','CL',35,'F2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('TT','Thường trực ngày thường','TR',36,'TT')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('TN','Thường trực ngày chủ nhật','TR',37,'TN')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('TT','Thường trực ngày lễ tết','TR',38,'TL')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('HT','Thường trực hồi sức ngày thường','TR',39,'HT')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('HN','Thường trực hồi sức ngày chủ nhật','TR',40,'HN')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('HT','Thường trực hồi sức ngày lễ tết','TR',41,'HL')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('KS','Làm ca sáng','CL',42,'KS')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('KC','Làm ca chiều','CL',43,'KC')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('ND','Làm ca đêm','CL',44,'KD')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('BU','Nghỉ bù ngày làm hành chính','CL',45,'BU')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('U2','Nghỉ bù ngày làm hành chính nửa ngày','CL',46,'U2')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('NL','Nghỉ lễ tết','CL',46,'NL')");
            mDB.Execute_data(" insert into " + user + ".dmlydo_phep(ma,ten,nhombc,stt,kihieu_phep) values('E2','Nghỉ lễ tết nửa ngày','CL',47,'E2')");


            sql = " alter table " + user + ".dmlydo_phep add column nhombc varchar(2)";
            mDB.Execute_data(sql);
            sql = " alter table " + user + ".dmlydo_phep add column kihieu_phep varchar(3)";
            mDB.Execute_data(sql);
            sql = " alter table " + user + ".chamcong_thuongtruc add column ts_ngayton numeric(3) default 0";
            mDB.Execute_data(sql);
            //
            mDB.Execute_data("alter table " + user + ".llnv alter column tdnn type varchar(2)");
            mDB.Execute_data("alter table " + user + ".llnv alter column tdnn1 type varchar(2)");
            mDB.Execute_data("alter table " + user + ".llnv alter column tdnn2 type varchar(2)");
            mDB.Execute_data("alter table " + user + ".llnv alter column tdnn3 type varchar(2)");
            //ngay 1509 them column vao bang llnv
            mDB.Execute_data(" alter table " + user + ".llnv add column ngaychuyendi_dang timestamp");
            mDB.Execute_data(" alter table " + user + ".llnv add column noichuyendi_dang text");
            mDB.Execute_data(" alter table " + user + ".llnv add column noichuyenden_dang text");
            sql = "alter table " + user + ".llnv add namtn varchar(4) default '';";
            mDB.Execute_data(sql);
            sql = "alter table " + user + ".llnv add manv_ms varchar(5) default '';";
            mDB.Execute_data(sql);
            sql = "alter table " + user + ".llnv add manv_ht varchar(5) default '';";
            mDB.Execute_data(sql);
            mDB.Execute_data(" alter table " + user + ".llnv add column ten_nd text");
            mDB.Execute_data(" alter table " + user + ".llnv add column ngayud timestamp");
            // them cot macc dung cho bv ha giang
            mDB.Execute_data(" alter table " + user + ".llnv add column macc varchar(50) default 0");
            //
            mDB.Execute_data("alter table " + user + ".pwhuman add makp varchar(3);");
            mDB.Execute_data("alter table   " + user + ".thebhyt  alter column captai type varchar(8);");
            mDB.Execute_data("alter table   " + user + ".thebhyt  alter column tai_bvien type varchar(8);");
            mDB.Execute_data("alter table   " + user + ".thebhyt  alter column sobhyt type varchar(25);");
            mDB.Execute_data("alter table   " + user + ".giacanh  add  id numeric not null DEFAULT 0; ");
            mDB.Execute_data("update " + user + ".giacanh  set id = to_number(oid) ;");
            mDB.Execute_data("alter table " + user + ".giacanh drop CONSTRAINT pk_giacanh;");
            mDB.Execute_data("alter table " + user + ".giacanh add column ghichu text");
            mDB.Execute_data(" ALTER TABLE " + user + ".giacanh  ADD CONSTRAINT pk_gcanh PRIMARY KEY(id) USING INDEX TABLESPACE pg_default;");
            mDB.Execute_data(" alter table " + user + ".giacanh add column ten_nd text");
            mDB.Execute_data(" alter table " + user + ".giacanh add column ngayud timestamp");
            //
            mDB.Execute_data(" alter table " + user + ".congviec add column kt_ct numeric(1,0) default 0");
            mDB.Execute_data(" alter table " + user + ".congviec add column tunam varchar(4)");
            mDB.Execute_data(" alter table " + user + ".congviec add column dennam varchar(4)");

            mDB.Execute_data(" alter table " + user + ".congviec alter column tunam type  varchar(7)");
            mDB.Execute_data(" alter table " + user + ".congviec alter column dennam type varchar(7)");

            mDB.Execute_data("drop view " + user + ".v_qtdaotao");
            mDB.Execute_data(" alter table " + user + ".qtdaotao alter column tunam type varchar(7)");
            mDB.Execute_data(" alter table " + user + ".qtdaotao alter column dennam type varchar(7)");
 
            mDB.Execute_data(" alter table " + user + ".congviec add column macd varchar(2)");
            mDB.Execute_data(" alter table   " + user + ".congviec  add  id numeric not null  DEFAULT 0;");
            mDB.Execute_data(" update " + user + ".congviec  set id = to_number(oid) ;");
            mDB.Execute_data(" alter table " + user + ".congviec  ADD CONSTRAINT pk_congviec PRIMARY KEY(id) USING INDEX TABLESPACE pg_default;");
            mDB.Execute_data(" alter table " + user + ".congviec add column ten_nd text");
            mDB.Execute_data(" alter table " + user + ".congviec add column ngayud timestamp");
            mDB.Execute_data(" alter table " + user + ".congviec add column hs_chucvu numeric default 0");
            mDB.Execute_data(" alter table " + user + ".congviec add column tn_vuotkhung numeric default 0");
            mDB.Execute_data(" alter table " + user + ".congviec add column tn_nghe numeric default 0");
            mDB.Execute_data(" alter table " + user + ".congviec add column hs_khac numeric default 0");
            //6/5/2011
            mDB.Execute_data(" alter table " + user + ".xuatcanh add column tunam varchar(4)");
            mDB.Execute_data(" alter table " + user + ".xuatcanh add column dennam varchar(4)");
            mDB.Execute_data(" alter table " + user + ".xuatcanh add column ten_nd text");
            mDB.Execute_data(" alter table " + user + ".xuatcanh add column ngayud timestamp");

            mDB.Execute_data(" alter table " + user + ".hphi add column id numeric default 0 not null");
            mDB.Execute_data(" alter table " + user + ".hphi add column donvi text");
            mDB.Execute_data(" alter table " + user + ".hphi drop constraint pk_hphi;");
            mDB.Execute_data(" alter table " + user + ".hphi add constraint pk_hphi primary key (id);");

            mDB.Execute_data(" alter table " + user + ".qtdaotao add column tunam varchar(4)");
            mDB.Execute_data(" alter table " + user + ".qtdaotao add column dennam varchar(4)");

            mDB.Execute_data(" alter table " + user + ".qtdaotao add column id numeric default 0 not null;");
            mDB.Execute_data(" alter table " + user + ".qtdaotao add column donvi text;");
            mDB.Execute_data(" alter table " + user + ".qtdaotao add constraint qtdaotao_pkey primary key (id);");
            mDB.Execute_data(" update " + user + ".qtdaotao  set id = to_number(oid);");
            mDB.Execute_data(" alter table " + user + ".qtdaotao add column ten_nd text");
            mDB.Execute_data(" alter table " + user + ".qtdaotao add column ngayud timestamp");
            mDB.Execute_data(" alter table " + user + ".qtdaotao add column noi_dt text");

            mDB.Execute_data("alter table   " + user + ".suckhoe  add  id numeric not null DEFAULT 0; ");
            mDB.Execute_data("update " + user + ".suckhoe  set id = to_number(oid) ;");
            mDB.Execute_data(" alter table " + user + ".suckhoe add column ten_nd text");
            mDB.Execute_data(" alter table " + user + ".suckhoe add column ngayud timestamp");
            //ma ngach
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b1 type numeric(5,2);");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b2 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b3 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b4 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b5 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b6 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b7 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b8 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b9 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b10 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b11 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  alter column b12 type numeric(5,2) ;");
            mDB.Execute_data("alter table   " + user + ".mangach  add   column nhomngach varchar(2);");
            mDB.Execute_data("alter table   " + user + ".mangach  add   column stt numeric(3,0) default 0;");
            // them va chinh sua cot stt trong cac bang danh muc
            mDB.Execute_data("alter table   " + user + ".tdnnth  add   column stt numeric(3,0) default 0;");
            mDB.Execute_data("alter table   " + user + ".mangach  add   column stt numeric(3,0) default 0;");
            mDB.Execute_data("alter table   " + user + ".ctdaotao  add   column stt numeric(3,0) default 0;");
            mDB.Execute_data("alter table   " + user + ".dmlydo_phep  add   column stt numeric(3,0) default 0;");
            mDB.Execute_data("alter table   " + user + ".bophan  alter column sothutu type numeric(3,0) default 0;");
            mDB.Execute_data("alter table   " + user + ".dmcv  alter column stt type numeric(3,0) default 0;");
            mDB.Execute_data("alter table   " + user + ".dmcd  alter column thutu type numeric(3,0) default 0;");
            // cap nhat bang ccng
            mDB.Execute_data("alter table   " + user + ".ccng add column congviec text default 0;");
            mDB.Execute_data("alter table   " + user + ".ccng add column id numeric(10,0) default 0;");
            mDB.Execute_data("alter table " + user + ".ccng drop constraint ccng_pkey");
            mDB.Execute_data("alter table " + user + ".ccng add constraint ccng_pkey PRIMARY KEY (manv,mmyy,id)");
            //tao them bang van tay
            sql = " CREATE TABLE " + user + ".vantay";
            sql += "(";
            sql += "  manv varchar(8) NOT NULL,";
            sql += "  kytu bytea,";
            sql += "  hinhanh_vt bytea,";
            sql += "  layvantay bool,";
            sql += " CONSTRAINT pk_vantay PRIMARY KEY (manv) USING INDEX TABLESPACE pg_default";
            sql += ")";
            mDB.Execute_data(sql);
            //them bang quy dinh som tre cham cong van tay
            sql = " CREATE TABLE " + user + ".dm_quydinhchamcong";
            sql += " (";
            sql += " ma numeric(2) NOT NULL DEFAULT 0,";
            sql += " ten text,";
            sql += " tu numeric(4) DEFAULT 0,";
            sql += " den numeric(4) DEFAULT 0,";
            sql += " solan numeric(2) DEFAULT 0,";
            sql += " songay numeric(2,1) DEFAULT 0,";
            sql += " kyhieu varchar(2),";
            sql += " vao numeric(1) DEFAULT 0,";
            sql += " ra numeric(1) DEFAULT 0,";
            sql += " manhom varchar(2),";
            sql += " CONSTRAINT dm_quydinhchamcong_pkey PRIMARY KEY (ma)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE " + user + ".dm_quydinhchamcong OWNER TO medisoft;";
            mDB.Execute_data(sql);
            // them bang nhom cham cong dung cho cham cong van tay
            sql = " CREATE TABLE nhansu.nhom_chamcong";
            sql += " (";
            sql += " ma varchar(2) NOT NULL,";
            sql += " ten text,";
            sql += " ghichu text,";
            sql += " CONSTRAINT nhom_chamcong_pkey PRIMARY KEY (ma)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE nhansu.nhom_chamcong OWNER TO medisoft;";
            mDB.Execute_data(sql);
            mDB.Execute_data(" insert into " + user + ".nhom_chamcong(ma,ten,ghichu) values('HC','Giờ hành chính nguyên ngày','')");
            mDB.Execute_data(" insert into " + user + ".nhom_chamcong(ma,ten,ghichu) values('HN','Giờ hành chính nửa ngày','')");
            mDB.Execute_data(" insert into " + user + ".nhom_chamcong(ma,ten,ghichu) values('NG','Chấm công ngoài giờ','')");
            mDB.Execute_data(" insert into " + user + ".nhom_chamcong(ma,ten,ghichu) values('TC','Chấm công trực tăng cường','')");
            mDB.Execute_data(" insert into " + user + ".nhom_chamcong(ma,ten,ghichu) values('TQ','Chấm công thường quy','')");
            mDB.Execute_data(" insert into " + user + ".nhom_chamcong(ma,ten,ghichu) values('TR','Chấm công thường trực','')");
            mDB.Execute_data(" insert into " + user + ".nhom_chamcong(ma,ten,ghichu) values('CD','Thứ 7 nguyên ngày','')");
            mDB.Execute_data(" insert into " + user + ".nhom_chamcong(ma,ten,ghichu) values('CN','Thứ 7 nửa ngày','')");
            // ngay 18-01 tao them bang table
            sql = " CREATE TABLE " + user + ".table ";
            sql += " (";
            sql += " mmyy varchar(4) NOT NULL,";
            sql += " userid numeric(5) DEFAULT 0,";
            sql += " ngayud timestamp DEFAULT now(),";
            sql += " computer varchar(20),";
            sql += " bak numeric(1) DEFAULT 0,";
            sql += " CONSTRAINT pk_table PRIMARY KEY (mmyy)";
            sql += " ) WITH OIDS;";
            sql += " ALTER TABLE " + user + ".table OWNER TO medisoft;";
            mDB.Execute_data(sql);
            //them bang ngay nghi le va nghi bu le trong nam
            sql = " CREATE TABLE nhansu.dmngayle";
            sql += " (";
            sql += " ngay timestamp NOT NULL,";
            sql += " lydo text,";
            sql += " loai numeric(1) DEFAULT 0,";
            sql += " mmyy varchar(4),";
            sql += " CONSTRAINT pk_dmngayle PRIMARY KEY (ngay)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE nhansu.dmngayle OWNER TO medisoft;";
            sql += " COMMENT ON COLUMN nhansu.dmngayle.loai IS '0: nghi le";
            sql += " 1: nghi bu le';";
            mDB.Execute_data(sql);

            // tao them bang luu danh muc mau bao cao
            sql = " create table " + user + ".dm_maubaocao";
            sql += " (";
            sql += " id numeric(10,0) not null,";
            sql += " maloai character varying(64),";
            sql += " tenloai     text,";
            sql += " ten         text,";
            sql += " filereport  character varying(64),";
            sql += " used        numeric(1,0)  default 1,";
            sql += " stt        numeric(7,0),";
            sql += " CONSTRAINT pk_dm_maubaocao PRIMARY KEY (id)";
            sql += " )";
            mDB.Execute_data(sql);
            // tao them bang cham cong ra
            sql = "CREATE TABLE " + user + ".ccra";
            sql += "(";
            sql += "manv varchar(5) NOT NULL DEFAULT 0,";
            sql += "somtre bool DEFAULT true,";
            sql += "lydo varchar(2),";
            sql += "maca numeric(2) NOT NULL DEFAULT 0,";
            sql += "ngay timestamp NOT NULL,";
            sql += "tgsomtre varchar(6) DEFAULT 0,";
            sql += "mmyy varchar(4) DEFAULT 0,";
            sql += "ngaynd timestamp,";
            sql += "thoigian timestamp,";
            sql += "kt_ng numeric(1) NOT NULL DEFAULT 0,";
            sql += "ghichu text,";
            sql += "CONSTRAINT ccra_pkey PRIMARY KEY (manv, ngay, maca,kt_ng)";
            sql += " )";
            mDB.Execute_data(sql);
            // tao them bang cham cong vao
            sql = "CREATE TABLE " + user + ".ccvao";
            sql += "(";
            sql += "manv varchar(5) NOT NULL DEFAULT 0,";
            sql += "somtre bool DEFAULT true,";
            sql += "lydo varchar(2),";
            sql += " maca numeric(2) NOT NULL DEFAULT 0,";
            sql += "ngay timestamp NOT NULL,";
            sql += "tgsomtre varchar(6) DEFAULT 0,";
            sql += "mmyy varchar(4) DEFAULT 0,";
            sql += "ngaynd timestamp,";
            sql += "thoigian timestamp,";
            sql += "kt_ng numeric(1) NOT NULL DEFAULT 0,";
            sql += "ghichu text,";
            sql += "CONSTRAINT ccvao_pkey PRIMARY KEY (manv, ngay, maca,kt_ng)";
            sql += ")";
            mDB.Execute_data(sql);
            // Tao them bang cham cong nghi
            sql = "CREATE TABLE " + user + ".ccnghi";
            sql += "(";
            sql += "manv varchar(5) NOT NULL,";
            sql += "ngay timestamp NOT NULL DEFAULT now(),";
            sql += " maca varchar(2) NOT NULL,";
            sql += "lydo text,";
            sql += " mmyy varchar(4),";
            sql += "ngay_ud timestamp DEFAULT now(),";
            sql += "ghichu text,";
            sql += " CONSTRAINT ccnghi_pkey PRIMARY KEY (manv, ngay, maca)";
            sql += ")";
            mDB.Execute_data(sql);
            //
            sql = "CREATE TABLE " + user + ".nhomcd( ma varchar(2) NOT NULL,  ten text, ";
            sql += " CONSTRAINT pk_nhomcd PRIMARY KEY (ma)) WITH OIDS; ";
            sql += " ALTER TABLE " + user + ".nhomcd OWNER TO medisoft;";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('01','Bác sĩ')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('02','Dược sỹ')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('03','Y tá')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('04','Y sỹ')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('05','Kỹ thuật viên')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('06','Nữ hộ sinh')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('07','Dược tá')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('08','Dược sỹ trung học')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('09','Khác')";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhomcd(ma,ten) values ('10','Kế toán')";
            mDB.Execute_data(sql);
            //cap nhat du lieu cho bang nhom ct dao tao
            mDB.Execute_data(" delete from " + user + ".dmnhomctdt");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('01','Bác sỹ')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('02','Dược')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('03','Dược tá')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('04','Kỹ thuật viên Y')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('05','Y tế công cộng')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('06','Y tá, điều dưỡng')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('07','Y sỹ')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('08','Hộ sinh')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('09','Hộ lý, Y công')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('10','Lương y')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('11','Công đoàn')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('12','Kế toán')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('13','Tin học')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('14','NV Kỹ thuật')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('15','Khác')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('16','Nha sỹ')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('17','Kỹ thuật viên dược')");
            mDB.Execute_data(" insert into " + user + ".dmnhomctdt(manhom,tennhom) values('18','Lương dược')");
            //
            sql = " CREATE OR REPLACE FUNCTION " + user + ".dateadd(character varying, integer, date) \n";
            sql += " RETURNS date AS \n";
            sql += " $BODY$ \n";
            sql += " DECLARE \n";
            sql += " p_Interval ALIAS FOR $1; \n";
            sql += " p_N ALIAS FOR $2; \n";
            sql += " p_Date ALIAS FOR $3; \n";
            sql += " BEGIN \n";
            sql += " if p_Interval = 'm' then \n";
            sql += " return p_Date + cast(p_N || ' months' as interval); \n";
            sql += " elseif p_Interval = 'y' then \n";
            sql += " return p_Date + cast(p_N || ' years' as interval); \n";
            sql += " else \n";
            sql += " raise exception 'dateadd interval parameter not supported'; \n";
            sql += " -- raise exception 'hello'; \n";
            sql += " return null; \n";
            sql += " end if; \n";
            sql += " END; \n";
            sql += " $BODY$ \n";
            sql += " LANGUAGE 'plpgsql'; \n";
            //MessageBox.Show(sql);
            mDB.Execute_data(sql);
            //            
            if (mDB.get_data("select * from " + user + ".thongso where id=15").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (15,'Nghĩ việc','0')";
                mDB.Execute_data(sql);
            }
            //
            if (mDB.get_data("select * from " + user + ".thongso where id=16").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (16,'Danh gia cbcc','0')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=17").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (17,'Gio kt cc','10:00')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=18").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (18,'Xephang','')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=19").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (19,'Giamdoccty','')";
                mDB.Execute_data(sql);
            }
           
            if (mDB.get_data("select * from " + user + ".thongso where id=20").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (20,'noimtk','')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=20").Tables[0].Rows.Count == 1)
            {
                sql = "update " + user + ".thongso set loai='noimtk' where id=20";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=21").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (21,'sodkt','')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=21").Tables[0].Rows.Count == 1)
            {
                sql = "update " + user + ".thongso set loai='sodkt' where id=21";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=22").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (22,'sohieutkvn','')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=22").Tables[0].Rows.Count == 1)
            {
                sql = "update " + user + ".thongso set loai='sohieutkvn' where id=22";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=23").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (23,'matt','')";
                mDB.Execute_data(sql);
            }           
           
            if (mDB.get_data("select * from " + user + ".thongso where id=24").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (24,'msthue','')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=24").Tables[0].Rows.Count == 1)
            {
                sql = "update " + user + ".thongso set loai='msthue' where id=24";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=26").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (26,'website','0')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=28").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (28,'fax','0')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=29").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (29,'tp_tochuc','0')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=30").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (30,'pkhth','0')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=31").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (31,'g_ccchieu','')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=32").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (32,'nhap_macc','0')";
                mDB.Execute_data(sql);
            }
            if (mDB.get_data("select * from " + user + ".thongso where id=33").Tables[0].Rows.Count == 0)
            {
                sql = "insert into " + user + ".thongso(id,loai,ten) values (33,'cc_tructc','0')";
                mDB.Execute_data(sql);
            }          
            //
            sql = "create table " + user + ".lichlv (maca numeric not null DEFAULT 0,tenca varchar(20),";
            sql += " batdau varchar(5),ketthuc varchar(5),sophuttre numeric DEFAULT 0,";
            sql += " sophutsom numeric DEFAULT 0,ktravao numeric DEFAULT 0,ktrara numeric DEFAULT 0,";
            sql += " batdauvao varchar(5),ketthucvao varchar(5),batdaura varchar(5),ketthucra varchar(5),mau varchar(20),tinhngay numeric DEFAULT 0,manhom varchar(2), ";
            sql += " CONSTRAINT pk_lichlv PRIMARY KEY (maca) USING INDEX TABLESPACE medi_index";
            sql += ")";
            mDB.Execute_data(sql);           
            //
            mDB.Execute_data("alter table  " + user + ".mahd  add  nhombc numeric DEFAULT 0; ");
            mDB.Execute_data(sql);
            sql = " CREATE TABLE " + user + ".nhombc( manhom numeric not null DEFAULT 0,  tennhom text,  CONSTRAINT pk_nhombc PRIMARY KEY (manhom)) WITH OIDS;ALTER TABLE " + user + ".nhombc OWNER TO medisoft; ";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhombc(manhom,tennhom) values (1,'Biến chế');";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhombc(manhom,tennhom) values (2,'HĐ Trong biên chế');";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhombc(manhom,tennhom) values (3,'HĐ Ngoài biên chế');";
            mDB.Execute_data(sql);
            sql = "insert into " + user + ".nhombc(manhom,tennhom) values (4,'HĐ Lương khoán');";
            mDB.Execute_data(sql);
            //
            sql = "CREATE TABLE " + user + ".dmnganhang(ma numeric not null DEFAULT 0, ";
            sql += " tennganhang text,  CONSTRAINT pk_dmnganhang PRIMARY KEY (ma)) WITH OIDS;";
            sql += " ALTER TABLE " + user + ".dmnganhang OWNER TO medisoft; ";
            mDB.Execute_data(sql);

            // them khoa chinh va du lieu vao bang loaingach
            mDB.Execute_data("alter table " + user + ".loaingach add column id numeric(2)");
            mDB.Execute_data("alter table " + user + ".loaingach add CONSTRAINT pk_loaingach PRIMARY KEY(id) USING INDEX TABLESPACE pg_default;");
            mDB.Execute_data(" insert into " + user + ".loaingach(id,loaingach) values(1,'A')");
            mDB.Execute_data(" insert into " + user + ".loaingach(id,loaingach) values(2,'A0')");
            mDB.Execute_data(" insert into " + user + ".loaingach(id,loaingach) values(3,'A1')");
            mDB.Execute_data(" insert into " + user + ".loaingach(id,loaingach) values(4,'A2')");
            mDB.Execute_data(" insert into " + user + ".loaingach(id,loaingach) values(5,'A3')");
            mDB.Execute_data(" insert into " + user + ".loaingach(id,loaingach) values(6,'B')");
            mDB.Execute_data(" insert into " + user + ".loaingach(id,loaingach) values(7,'C')");
            //ngay 1509 cap nhap bac cuoi cho bang ma ngach
            mDB.Execute_data(" alter table " + user + ".mangach add column baccuoi numeric(2) default 0");
            mDB.Execute_data(" alter table " + user + ".mangach add column hs_cuoi numeric(5,2) default 0");
            mDB.Execute_data(" alter table " + user + ".mangach add constraint pk_mangach PRIMARY KEY (ma)");
            mDB.Execute_data(" update " + user + ".mangach set baccuoi=6 where loaingach='A3'");
            mDB.Execute_data(" update " + user + ".mangach set baccuoi=8 where loaingach='A2'");
            mDB.Execute_data(" update " + user + ".mangach set baccuoi=9 where loaingach='A1'");
            mDB.Execute_data(" update " + user + ".mangach set baccuoi=10 where loaingach='A0'");
            mDB.Execute_data(" update " + user + ".mangach set baccuoi=12 where loaingach='B'");
            mDB.Execute_data(" update " + user + ".mangach set baccuoi=12 where loaingach='C'");
            //them view All hopdong           
            sql = " CREATE OR REPLACE VIEW " + user + ".All_HopDong AS";
            sql += " SELECT hd.manv,hd.madv,hd.manvmay,hd.stt,hd.hdldso,hd.ngayhd,hd.loaihd";
            sql += " ,hd.tungay,hd.denngay,hd.thoigian,hd.macv,hd.ngaybn,hd.tgbn,hd.luonghd";
            sql += " ,hd.thuongvp,hd.ngaydenct,hd.chuyenct,hd.ngungct,hd.ngaynghi,hd.sonphep";
            sql += " ,hd.dang,hd.thedang,hd.chuyen_den,hd.chi_bo,hd.cong_doan,hd.tocd";
            sql += " ,hd.the_cdoan,hd.cdoanphi,hd.vao_cdoan,hd.doan,hd.doan_den,hd.todoan";
            sql += " ,hd.thedoan,hd.doanphi,hd.sobhxh,hd.tgbhxh,hd.k_tinhbhxh,hd.sld_tudau";
            sql += " ,hd.sld_ngaydi,hd.ngaybhxh,hd.dacdiem,hd.nhandang,hd.max_dang,hd.max_doan";
            sql += " ,hd.max_cquyen,hd.cmax_dang,hd.cmax_doan,hd.cmax_quyen,hd.s_begin,hd.bhyt";
            sql += " ,hd.bhxh,hd.bhtn,hd.c_thich_cv,hd.hs_cv,hd.hs_tn,hd.hs_dh,hd.hs_ld,hd.hs_db";
            sql += " ,hd.hs_kv,hd.hs_lc,hd.hs_th,hd.hs_ud,hd.luongct,hd.mangach,hd.hs_lcu,hd.heso";
            sql += " ,hd.hs_dt,hd.namqlnn,hd.hs_vk,hd.ngayvk,hd.tlvkcu,hd.matd,hd.ngaydkta,hd.ngaydkga";
            sql += " ,hd.nthuviec,hd.nhopdong,hd.dihocnn,hd.ktinhluong,hd.ghichu,hd.magc,hd.tdqlnn";
            sql += " ,hd.ngaytd,hd.ngayctnn,hd.noi_doanden,hd.noi_chuyenden,hd.tbnghihuu,hd.bangkhen,hd.thangnangluong";
            sql += " ,hd.phepthem,hd.ngaybnngach,hd.ngay_tapsu,hd.tg_tapsu,hd.chinhthuc_lv,hd.luong_tapsu,hd.loaingach, hd.ko_hoanthanh";
            sql += " ,hd.nam,hd.loaibn,hd.ngayphepnam,hd.loaihuongphep,hd.ghichuphep,hd.thaisan,hd.lydonghi,hd.to_t, hd.bac, hd.lan";
            sql += " ,hd.luuy,hd.ld_nghiviec,hd.tvtungay,hd.tvdenngay,hd.dg1,hd.dg2,hd.dg3,hd.dg4,hd.dg5, hd.dg6, hd.dg7, hd.dg8, hd.dg9, hd.dg10, hd.dg11";
            sql += " ,hd.pc_khac,ghichuct text,sotien_hd,pc_tx,hd.pc_ta,ten_nd,ngayud,songay_lv,thuongkhac,ngaygiulhd,lhd_bantg,st_bantg,luong_sp,pc_tdt,tongluong";
            sql += " FROM " + user + ".hopdong hd";
            sql += " JOIN " + user + ".llnv ON llnv.manv::text = hopdong.manv::text;";
            sql += " ALTER TABLE " + user + ".All_HopDong OWNER TO medisoft;";
            mDB.Execute_data(sql);

            sql = " CREATE OR REPLACE VIEW " + user + ".max_lan AS";
            sql += " SELECT hd.manv, max(hd.lan) AS lan";
            sql += " FROM " + user + ".hopdong hd";
            sql += " GROUP BY hd.manv";
            sql += " ORDER BY hd.manv;";
            sql += " ALTER TABLE " + user + ".max_lan OWNER TO medisoft;";
            sql += " COMMENT ON VIEW " + user + ".max_lan IS 'Lay lan ky hop dong gan nhat';";
            mDB.Execute_data(sql);

            //ngay 1010 sua them lay manv
            sql = " CREATE SEQUENCE " + user + ".max_manv";
            sql += " INCREMENT 1";
            sql += " MINVALUE 1";
            sql += " MAXVALUE 9223372036854775807";
            sql += " START 1";
            sql += " CACHE 1;";
            sql += " ALTER TABLE " + user + ".max_manv OWNER TO medisoft;";
            mDB.Execute_data(sql);
            sql = " CREATE OR REPLACE VIEW " + user + ".tdnn1 AS";
            sql += " SELECT tdnnth.ma, tdnnth.ten,tdnnth.ngoaingu,tdnnth.tinhoc,tdnnth.nhombc";
            sql += " FROM " + user + ".tdnnth";
            sql += " WHERE tdnnth.ngoaingu = true";
            sql += " ORDER BY tdnnth.ma;";
            sql += " ALTER TABLE " + user + ".tdnn1 OWNER TO medisoft;";
            mDB.Execute_data(sql);
            sql = " CREATE OR REPLACE VIEW " + user + ".tdnn2 AS";
            sql += " SELECT tdnnth.ma, tdnnth.ten,tdnnth.ngoaingu,tdnnth.tinhoc,tdnnth.nhombc";
            sql += " FROM " + user + ".tdnnth";
            sql += " WHERE tdnnth.ngoaingu = true";
            sql += " ORDER BY tdnnth.ma;";
            sql += " ALTER TABLE " + user + ".tdnn2 OWNER TO medisoft;";
            mDB.Execute_data(sql);
            sql = " CREATE OR REPLACE VIEW " + user + ".tdnn3 AS";
            sql += " SELECT tdnnth.ma, tdnnth.ten,tdnnth.ngoaingu,tdnnth.tinhoc,tdnnth.nhombc";
            sql += " FROM " + user + ".tdnnth";
            sql += " WHERE tdnnth.ngoaingu = true";
            sql += " ORDER BY tdnnth.ma;";
            sql += " ALTER TABLE " + user + ".tdnn3 OWNER TO medisoft;";
            mDB.Execute_data(sql);
            sql = " CREATE OR REPLACE VIEW " + user + ".tdnn4 AS";
            sql += " SELECT tdnnth.ma, tdnnth.ten, tdnnth.ngoaingu, tdnnth.tinhoc,tdnnth.nhombc";
            sql += " FROM " + user + ".tdnnth";
            sql += " WHERE tdnnth.ngoaingu = true";
            sql += " ORDER BY tdnnth.ma;";
            sql += " ALTER TABLE " + user + ".tdnn4 OWNER TO medisoft;";
            mDB.Execute_data(sql);
            // ngay 16/11 them cot thuong tat va loai thuong tat vao bang suc khoe
            mDB.Execute_data(" alter table " + user + ".suckhoe add column thuongtat bool default false");
            mDB.Execute_data(" alter table " + user + ".suckhoe add column loai_tt text");
            mDB.Execute_data(" alter table " + user + ".hopdong add column ghichuct text");
            sql = " CREATE OR REPLACE VIEW " + user + ".v_qtdaotao AS";
            sql += " SELECT q.manv, q.mahv, c.tenctdt, q.mabangcap, b.tenbang, q.hehocvan, d.tenhe, q.thang, q.tungay,q.tunam, q.denngay,q.dennam, q.ghichu, q.id, q.donvi,q.noi_dt";
            sql += " FROM " + user + ".qtdaotao q";
            sql += " JOIN " + user + ".bangcap b ON q.mabangcap::text = b.mabangcap::text";
            sql += " JOIN " + user + ".ctdaotao c ON q.mahv::text = c.mactdt::text";
            sql += " LEFT JOIN " + user + ".hedaotao d ON q.hehocvan::text = d.mahe::text;";
            sql += " ALTER TABLE " + user + ".v_qtdaotao OWNER TO medisoft;";
            mDB.Execute_data(sql);
            sql = " CREATE OR REPLACE VIEW " + user + ".gcanh_con AS";
            sql += " SELECT gc.manv, sum(";
            sql += " CASE WHEN gc.madt::text = 'C1'::text OR gc.madt::text = 'C2'::text THEN 1 ELSE 0 END) AS socon";
            sql += " FROM " + user + ".giacanh gc";
            sql += " GROUP BY gc.manv;";
            sql += " ALTER TABLE " + user + ".gcanh_con OWNER TO medisoft;";
            sql += " COMMENT ON VIEW " + user + ".gcanh_con IS 'dem so con';";
            mDB.Execute_data(sql);
           
            // them bang nhomngach
            sql = " CREATE TABLE " + user + ".nhomngach";
            sql += " (";
            sql += " manhom varchar(2) NOT NULL,";
            sql += " tennhom text,";
            sql += " CONSTRAINT nhomngach_pkey PRIMARY KEY (manhom)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE " + user + ".nhomngach OWNER TO medisoft;";
            mDB.Execute_data(sql);
            // ngay 29/12 chinh sua kieu du lieu cua cot hscv trong bang dmcv
            mDB.Execute_data(" alter table " + user + ".dmcv alter column hscv type numeric(12,2)");
            //ngay 02-04 them field letet va t7cn trong bang ccng
            mDB.Execute_data(" alter table " + user + ".ccng add column letet bool default false ");
            mDB.Execute_data(" alter table " + user + ".ccng add column t7cn bool default false ");
            int m_manv;
            string s_manv = mDB.get_data(" select max(to_number(manv)) as manv from " + user + ".llnv").Tables[0].Rows[0]["manv"].ToString();
            if (s_manv == "")
            {
                m_manv = 0;
            }
            else
            {
                m_manv = int.Parse(s_manv);
            }
            sql = " ALTER SEQUENCE " + user + ".max_manv";
            sql += " RESTART WITH " + m_manv;
            mDB.Execute_data(sql);

            DataTable dttemp = new DataTable();
            dttemp = mDB.get_data("select nganhang from " + user + ".llnv where 1=0").Tables[0];
            if (dttemp.Columns[0].DataType.ToString() == "System.String")
            {
                mDB.Execute_data("alter table " + user + ".llnv drop column nganhang ");
                mDB.Execute_data("alter table " + user + ".llnv add column nganhang numeric;");
            }
            // them bang cham cong thuong truc
            sql = " CREATE TABLE " + user + ".chamcong_thuongtruc";
            sql += " ( manv varchar(5) NOT NULL DEFAULT 0,";
            sql += " madv varchar(3) NOT NULL DEFAULT 0,";
            sql += " mmyy varchar(5) NOT NULL DEFAULT 0,";
            sql += " n1 varchar(2),";
            sql += " n2 varchar(2),";
            sql += " n3 varchar(2),";
            sql += " n4 varchar(2),";
            sql += " n5 varchar(2),";
            sql += " n6 varchar(2),";
            sql += " n7 varchar(2),";
            sql += " n8 varchar(2),";
            sql += " n9 varchar(2),";
            sql += " n10 varchar(2),";
            sql += " n11 varchar(2),";
            sql += " n12 varchar(2),";
            sql += " n13 varchar(2),";
            sql += " n14 varchar(2),";
            sql += " n15 varchar(2),";
            sql += " n16 varchar(2),";
            sql += " n17 varchar(2),";
            sql += " n18 varchar(2),";
            sql += " n19 varchar(2),";
            sql += " n20 varchar(2),";
            sql += " n21 varchar(2),";
            sql += " n22 varchar(2),";
            sql += " n23 varchar(2),";
            sql += " n24 varchar(2),";
            sql += " n25 varchar(2),";
            sql += " n26 varchar(2),";
            sql += " n27 varchar(2),";
            sql += " n28 varchar(2),";
            sql += " n29 varchar(2),";
            sql += " n30 varchar(2),";
            sql += " n31 varchar(2),";
            sql += " ts_ngayton numeric(3) DEFAULT 0,";
            sql += " CONSTRAINT chamcong_thuongtruc_pkey PRIMARY KEY (manv, mmyy)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE " + user + ".chamcong_thuongtruc OWNER TO medisoft;";
            mDB.Execute_data(sql);

            // them bang cham cong truc tang cuong
            sql = " CREATE TABLE " + user + ".chamcong_tructc";
            sql += " ( manv varchar(5) NOT NULL DEFAULT 0,";
            sql += " madv varchar(3) NOT NULL DEFAULT 0,";
            sql += " mmyy varchar(5) NOT NULL DEFAULT 0,";
            sql += " n1 varchar(2),";
            sql += " n2 varchar(2),";
            sql += " n3 varchar(2),";
            sql += " n4 varchar(2),";
            sql += " n5 varchar(2),";
            sql += " n6 varchar(2),";
            sql += " n7 varchar(2),";
            sql += " n8 varchar(2),";
            sql += " n9 varchar(2),";
            sql += " n10 varchar(2),";
            sql += " n11 varchar(2),";
            sql += " n12 varchar(2),";
            sql += " n13 varchar(2),";
            sql += " n14 varchar(2),";
            sql += " n15 varchar(2),";
            sql += " n16 varchar(2),";
            sql += " n17 varchar(2),";
            sql += " n18 varchar(2),";
            sql += " n19 varchar(2),";
            sql += " n20 varchar(2),";
            sql += " n21 varchar(2),";
            sql += " n22 varchar(2),";
            sql += " n23 varchar(2),";
            sql += " n24 varchar(2),";
            sql += " n25 varchar(2),";
            sql += " n26 varchar(2),";
            sql += " n27 varchar(2),";
            sql += " n28 varchar(2),";
            sql += " n29 varchar(2),";
            sql += " n30 varchar(2),";
            sql += " n31 varchar(2),";
            sql += " ts_ngayton numeric(3) DEFAULT 0,";
            sql += " CONSTRAINT chamcong_tructc_pkey PRIMARY KEY (manv, mmyy)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE " + user + ".chamcong_tructc OWNER TO medisoft;";
            mDB.Execute_data(sql);
            // them bang cham cong thuong quy
            sql = " CREATE TABLE nhansu.chamcong_thuongquy";
            sql += " ("; 
            sql += " manv text NOT NULL,"; 
            sql += " mmyy text NOT NULL,"; 
            sql += " ngay timestamp,"; 
            sql += " batdau timestamp,"; 
            sql += " ketthuc timestamp,"; 
            sql += " ghichu numeric,"; 
            sql += " hscc bool NOT NULL DEFAULT false,"; 
            sql += " ngaybatdau timestamp,"; 
            sql += " ngayketthuc timestamp,"; 
            sql += " letet bool DEFAULT false,"; 
            sql += " t7cn bool DEFAULT false,"; 
            sql += " id numeric(10) NOT NULL DEFAULT 0,"; 
            sql += " congviec text DEFAULT 0,"; 
            sql += " CONSTRAINT chamcong_thuongquy_pkey PRIMARY KEY (manv, mmyy, id)"; 
            sql += " )"; 
            sql += " WITHOUT OIDS;"; 
            sql += " ALTER TABLE "+user+".chamcong_thuongquy OWNER TO medisoft;";
            mDB.Execute_data(sql);
            sql = " CREATE TABLE "+user+".thuongquy";
            sql += " (";
            sql += " manv text NOT NULL,";
            sql += " mmyy text NOT NULL,";
            sql += " hoten text,";
            sql += " CONSTRAINT thuongquy_pkey PRIMARY KEY (manv, mmyy)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE "+user+".thuongquy OWNER TO medisoft;";
            mDB.Execute_data(sql);
            //them bang bangcapbc 
            sql = " CREATE TABLE " + user + ".bangcapbc";
            sql += " (";
            sql += " mabang varchar(2) NOT NULL,";
            sql += " tenbang varchar(254),";
            sql += " CONSTRAINT bangcapbc_pk PRIMARY KEY (mabang)";
            sql += " )";
            sql += " WITHOUT OIDS;";
            sql += " ALTER TABLE " + user + ".bangcapbc OWNER TO medisoft;";
            mDB.Execute_data(sql);
            //them du lieu vao bang nhom bang cap
            mDB.Execute_data(" delete from " + user + ".bangcapbc");
            mDB.Execute_data(" insert into " + user + ".bangcapbc(mabang,tenbang) values('TD','Trên đại học')");
            mDB.Execute_data(" insert into " + user + ".bangcapbc(mabang,tenbang) values('DH','Đại học')");
            mDB.Execute_data(" insert into " + user + ".bangcapbc(mabang,tenbang) values('CD','Cao đẳng')");
            mDB.Execute_data(" insert into " + user + ".bangcapbc(mabang,tenbang) values('TH','Trung hoc')");
            mDB.Execute_data(" insert into " + user + ".bangcapbc(mabang,tenbang) values('SH','Sơ học')");
            mDB.Execute_data(" insert into " + user + ".bangcapbc(mabang,tenbang) values('KH','Khác')");
            //them du lieu cho bang nhom ngach
            mDB.Execute_data(" delete from " + user + ".nhomngach");
            mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('CC','Chuyên viên cao cấp và TĐ')");
            mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('VC','Chuyên viên chính và TĐ')");
            mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('CV','Chuyên viên và TĐ')");
            mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('CS','Cán sự và TĐ')");
            mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('NV','Nhân viên và TĐ')");
            //mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('DH','Đại học')");
            //mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('CD','Cao đẳng')");
            //mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('TH','Hai năm')");
            //mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('SH','Một năm')");
            //mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('6T','Sáu tháng')");
            //mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('3T','Ba tháng')");
            //mDB.Execute_data(" insert into " + user + ".nhomngach(manhom,tennhom) values('KH','Không bằng cấp')");
            // them cot letet trong bang cham cong ngoai gio
            mDB.Execute_data(" alter table " + user + ".ccng add column letet bool NOT NULL DEFAULT false");
            mDB.Execute_data(" alter table " + user + ".tdnnth add column nhombc varchar(2)");
           
            MessageBox.Show(lan.Change_language_MessageText("Xong!"), AccessData.Msg, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void dm_ngach()
        {
            mDB.Execute_data("delete from " + user + ".mangach");
            DataSet ds = new DataSet();
            ds.ReadXml("ngachcc.xml");
            foreach (DataRow r in ds.Tables[0].Rows)
            {
                mDB.Insert_DMNGACHCONGCHUC(r["ma"].ToString(), r["diengiai"].ToString(), (r["b1"].ToString() != "" ? decimal.Parse(r["b1"].ToString()) : 0),
                                           (r["b2"].ToString() != "" ? decimal.Parse(r["b2"].ToString()) : 0), (r["b3"].ToString() != "" ? decimal.Parse(r["b3"].ToString()) : 0),
                                           (r["b4"].ToString() != "" ? decimal.Parse(r["b4"].ToString()) : 0), (r["b5"].ToString() != "" ? decimal.Parse(r["b5"].ToString()) : 0),
                                           (r["b6"].ToString() != "" ? decimal.Parse(r["b6"].ToString()) : 0), (r["b7"].ToString() != "" ? decimal.Parse(r["b7"].ToString()) : 0),
                                           (r["b8"].ToString() != "" ? decimal.Parse(r["b8"].ToString()) : 0), (r["b9"].ToString() != "" ? decimal.Parse(r["b9"].ToString()) : 0),
                                           (r["b10"].ToString() != "" ? decimal.Parse(r["b10"].ToString()) : 0), (r["b11"].ToString() != "" ? decimal.Parse(r["b11"].ToString()) : 0),
                                           (r["b12"].ToString() != "" ? decimal.Parse(r["b12"].ToString()) : 0), "", r["loaingach"].ToString(), r["nhomngach"].ToString(), (r["stt"].ToString() != "" ? decimal.Parse(r["stt"].ToString()) : 0));
                mDB.Execute_data("update " + user + ".mangach set stt=" + r["stt"].ToString() + " where ma='" + r["ma"].ToString() + "'");
            }
        }
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmAbout f = new frmAbout("", null);
            f.MdiParent = this;
            f.Show();
        }
        private void helpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Help.ShowHelp(this, "Data\\Help_Nhansu.chm");
        }
        private void modifyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmload f = new frmload();
            f.Show();
            modi = new modify();
            modi.modify_data();
            f.Close();
        }
       
        #region Nhan vien

        private void kethucToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(lan.Change_language_MessageText("Bạn có muốn đóng chương trình không?"),AccessData.Msg,MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
                Application.Exit();
        }

        private void llnvToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmLyLichNV f1 = new frmLyLichNV(m_admin,user_dn);
            f1.MdiParent = this;
            f1.Show();
        }

        private void chamcongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string m_bp = "", s_mmyy = "", s_ngaylv = "";
            int m_thang = 0, m_nam = 0;
            frmChonngay f = new frmChonngay(s_makp,ngay_ht);
            f.ShowDialog();
            s_mmyy = f.s_mmyy;
            s_ngaylv = f.s_ngaylv;
            m_bp = f.m_bp;
            m_thang = f.p_thang;
            m_nam = f.p_nam;
            if (s_mmyy != "" && m_bp != "")
            {
                frmChamcong f1 = new frmChamcong(s_mmyy, s_ngaylv, m_bp, m_thang, m_nam,m_admin,user_dn);
                f1.MdiParent = this;
                f1.Show();
            }
        }
        private void chamcong_thuongtrucToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string m_bp = "", s_mmyy = "", s_ngaylv = "";
            int m_thang = 0, m_nam = 0;
            frmChonngay f = new frmChonngay(s_makp,ngay_ht);
            f.ShowDialog();
            s_mmyy = f.s_mmyy;
            s_ngaylv = f.s_ngaylv;
            m_bp = f.m_bp;
            m_thang = f.p_thang;
            m_nam = f.p_nam;
            if (s_mmyy != "" && m_bp != "")
            {
                frmChamcong_thuongtruc f1 = new frmChamcong_thuongtruc(s_mmyy, s_ngaylv, m_bp, m_thang, m_nam, m_admin,user_dn);
                f1.MdiParent = this;
                f1.Show();
            }
        }
        private void chamcong_ngoaigioToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string m_bp = "", s_mmyy = "", s_ngaylv = "";
            int m_thang = 0, m_nam = 0;
            frmChonngay f = new frmChonngay(s_makp,ngay_ht);
            f.ShowDialog();
            s_mmyy = f.s_mmyy;
            s_ngaylv = f.s_ngaylv;
            m_bp = f.m_bp;
            m_thang = f.p_thang;
            m_nam = f.p_nam;
            if (s_mmyy != "" && m_bp != "")
            {
                frmchamcong_ngoaigio f1 = new frmchamcong_ngoaigio(s_mmyy, s_ngaylv, m_bp, m_thang, m_nam, m_admin,user_dn);
                f1.MdiParent = this;
                f1.Show();
            }
        }
        private void cctructhuongquy_toolStripMenuItem_Click(object sender, EventArgs e)
        {
            string m_bp = "", s_mmyy = "", s_ngaylv = "";
            int m_thang = 0, m_nam = 0;
            frmChonngay f = new frmChonngay(s_makp, ngay_ht);
            f.ShowDialog();
            s_mmyy = f.s_mmyy;
            s_ngaylv = f.s_ngaylv;
            m_bp = f.m_bp;
            m_thang = f.p_thang;
            m_nam = f.p_nam;
            if (s_mmyy != "" && m_bp != "")
            {
                frmchamcong_thuongquy f1 = new frmchamcong_thuongquy(s_mmyy, s_ngaylv, m_bp, m_thang, m_nam, m_admin,user_dn);
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void cc_ngoaigio_bptoolStripMenuItem_Click(object sender, EventArgs e)
        {
            string m_bp = "", s_mmyy = "", s_ngaylv = "";
            int m_thang = 0, m_nam = 0;
            frmChonngay f = new frmChonngay(s_makp,ngay_ht);
            f.ShowDialog();
            s_mmyy = f.s_mmyy;
            s_ngaylv = f.s_ngaylv;
            m_bp = f.m_bp;
            m_thang = f.p_thang;
            m_nam = f.p_nam;
            if (s_mmyy != "" && m_bp != "")
            {
                frmchamcong_ngoaigio_bp f1 = new frmchamcong_ngoaigio_bp(s_mmyy, s_ngaylv, m_bp, m_thang, m_nam, m_admin,user_dn);
                f1.MdiParent = this;
                f1.Show();
            }
        }
        private void cctructc_toolStripMenuItem_Click(object sender, EventArgs e)
        {
            string m_bp = "", s_mmyy = "", s_ngaylv = "";
            int m_thang = 0, m_nam = 0;
            frmChonngay f = new frmChonngay(s_makp,ngay_ht);
            f.ShowDialog();
            s_mmyy = f.s_mmyy;
            s_ngaylv = f.s_ngaylv;
            m_bp = f.m_bp;
            m_thang = f.p_thang;
            m_nam = f.p_nam;
            if (s_mmyy != "" && m_bp != "")
            {
                frmtruc_tangcuong f1 = new frmtruc_tangcuong(s_mmyy, s_ngaylv, m_bp, m_thang, m_nam, m_admin,user_dn);
                f1.MdiParent = this;
                f1.Show();
            }
        }
        private void khenthuongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmKhenthuong f = new frmKhenthuong(s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }
        private void capnhatdienbienluongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_thaydoibl_pc f = new frm_thaydoibl_pc(m_admin,s_makp,user_dn);
            f.ShowDialog();
        }
        #endregion 
        #region truy van
        private void tuoitbToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDoTuoiTrungBinh frm = new frmDoTuoiTrungBinh();
            frm.ShowDialog(this);
        }
        private void ttgiadinhToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmThongKeTTGiaDinh frm = new frmThongKeTTGiaDinh();
            
            frm.ShowDialog();
        }

        private void tinhToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmTinhHinhCongViec frm = new frmTinhHinhCongViec();
            frm.MdiParent = this;
            frm.Show();
        }

        private void nghenghiepToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmNgheNghiepDaoTao frm = new frmNgheNghiepDaoTao();
            frm.MdiParent = this;
            frm.Show();
        }

        private void giacanhToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmTkgiacanh f = new frmTkgiacanh();
            f.MdiParent = this;
            f.Show();
        }

        private void nuocngoaiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDinuocngoai frm = new frmDinuocngoai();
            frm.MdiParent = this;
            frm.Show();
        }
        private void luongbqToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmMucLuongBQ frm = new frmMucLuongBQ();
            frm.ShowDialog();
        }
        #endregion              
        #region Bao cao Bao Hiem
        private void ldongqtlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDSLaoDongVaQuyLuongTrichNopBH frm = new frmDSLaoDongVaQuyLuongTrichNopBH(s_makp,user_dn);

            frm.ShowDialog();
        }

        private void tokhai_bhytbhxhToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_intokhaibhxh f = new frm_intokhaibhxh(s_makp,user_dn);
            f.ShowDialog();
        }
        private void dsdc_ldthamgiabhxh_thangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dsdcdongbhxh f = new frm_dsdcdongbhxh(s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }

        private void dsld_thamgiabhxh_thangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmds_bhxh_bhyt f = new frmds_bhxh_bhyt(s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }

        private void dsnv_dncapsobhxhToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDSDenghiCSBHXH frm = new frmDSDenghiCSBHXH(s_makp,user_dn);
            frm.ShowDialog();
        }

        #endregion
        #region Tienich
        private void phqToolStripMenuItem_Click(object sender, EventArgs e)
        {
            f_get_menu();
            frmRight f = new frmRight(mDB,m_admin);
            f.ShowDialog(this);
        }
        private void bpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLoaded("frmBophan")) return;
            frmBophan f = new frmBophan();
            f.MdiParent = this;
            f.Show();
        }

        private void cvToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (IsLoaded("frmChucv")) return; 
            frmChucv f = new frmChucv();
            f.MdiParent = this;
            f.Show();
        }

        private void hvToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLoaded("frmHocvan")) return; 
            frmHocvan f = new frmHocvan();
            f.MdiParent = this;
            f.Show();
        }

        private void nnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLoaded("frmNgoaingu")) return; 
            frmNgoaingu f = new frmNgoaingu();
            f.MdiParent = this;
            f.Show();
        }

        private void nndtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLoaded("frmNganhdaotao")) return; 
            frmNganhdaotao f = new frmNganhdaotao();
            f.MdiParent = this;
            f.Show();
        }

        private void bcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLoaded("frmBangcap")) return; 
            frmBangcap f = new frmBangcap();
            f.MdiParent = this;
            f.Show();
        }

        private void ndkkcbToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLoaded("frmDonvi")) return; 
            frmDonvi f = new frmDonvi();
            f.MdiParent = this;
            f.Show();
        }

        private void ldnvToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLoaded("frmNghiviec")) return;
            frmNghiviec f = new frmNghiviec();
            f.MdiParent = this;
            f.Show();
        }

        private void dantocToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (IsLoaded("frmDantoc")) return;
            frmDantoc f = new frmDantoc();
            f.MdiParent = this;
            f.Show();
        }

        private void hopdgToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            frmdmHopdong f = new frmdmHopdong();
            f.MdiParent = this;
            f.Show();
        }

        private void cdToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmChucDanh f = new frmChucDanh();
            f.MdiParent = this;
            f.Show();
        }

        private void tinhToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            frmBtdtt f = new frmBtdtt(mDB, 1);
            f.MdiParent = this;
            f.Show();
        }

        private void tpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmBtdquan f = new frmBtdquan(mDB);
            f.MdiParent = this;
            f.Show();
        }

        private void pxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmBtdpxa f = new frmBtdpxa(mDB, 1);
            f.MdiParent = this;
            f.Show();
        }

        private void cnngachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDanhMucNgachCongChuc frm = new frmDanhMucNgachCongChuc();
            frm.MdiParent = this;
            frm.Show();
        }

        private void intheToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_doingay f = new frm_doingay();
            f.MdiParent = this;
            f.Show();
            ngay_ht = f.d_ngay;
            //frmInthe f = new frmInthe();
            //f.ShowDialog();
        }

        private void thongsoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string m_thang = "", m_nam = "";
            frmCNHS f = new frmCNHS(user_dn);
            f.MdiParent = this;
            f.Show();
            //---
            m_thang = f.m_thang;
            m_nam = f.m_nam;
            if (m_nam != "" && m_thang != "")
            {
                frmcnheso h = new frmcnheso(m_thang, m_nam, m_admin);
                h.MdiParent = this;
                h.Show();
            }
        }
        private void chuyenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmChuyenData f = new frmChuyenData();
            f.MdiParent = this;
            f.Show();
        }

        private void foxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCvFox f = new frmCvFox();
            f.MdiParent = this;
            f.Show();
        }

        private void dtlmttToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }
        private void dmnganhangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmdmnganhang f = new frmdmnganhang();
            f.MdiParent = this;
            f.Show();
        }

        private void toolStripMenuItem14_Click(object sender, EventArgs e)
        {
            frmChonngay_tc f = new frmChonngay_tc();
            f.MdiParent = this;
            f.Show();
            if (f.closess)
            {
                frm_nvien_tangcuong f1 = new frm_nvien_tangcuong(f.thang, f.nam, f.s_mabp,user_dn,m_admin);
                f1.MdiParent = this;
                f1.Show();
            }
        }
        private void doimatkhautoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_doimatkhau f = new frm_doimatkhau(user_dn, pass);
            f.MdiParent = this;
            f.Show();
        }
        private void backup_datatoolStripMenuItem_Click(object sender, EventArgs e)
        {
            backup f;
            string ip, post, owner, user, database, file, arg, tenfile,
                ngay = DateTime.Now.Day.ToString().PadLeft(2, '0') + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Year.ToString().PadLeft(4, '0') + DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0');
            string s = "Nhansu//" + ngay + "//"; //path = thumuc.Text + "//" + ngay + "//";
            file = @"pg_dump.exe";
            user = mDB.user;
            ip = mDB.Maincode("Ip");
            post = mDB.Maincode("Post");
            owner = mDB.Maincode("UserID");
            if (owner == "") owner = "medisoft";
            database = mDB.Maincode("Database");
            if (!System.IO.Directory.Exists(s)) System.IO.Directory.CreateDirectory(s);
            tenfile = user;// backup tung schema
            //tenfile = database;// backup nguyen database
            arg = " -i -h " + ip + " -p " + post + " -U " + owner + " -F c -o -v -f " + s + tenfile + ".backup -n " + tenfile + " " + database;// backup tung schema
            //arg = " -i -h " + ip + " -p " + post + " -U " + owner + " -F c -b -v -f " + s + tenfile + ".backup  " + database;
            f = new backup(file, arg, true, true);
            f.Launch();
            foreach (DataRow r in mDB.get_data("select * from " + user + ".table where bak=0").Tables[0].Rows)
            {
                tenfile = user + r["mmyy"].ToString();
                arg = " -i -h " + ip + " -p " + post + " -U " + owner + " -F c -o -v -f " + s + tenfile + ".backup -n " + tenfile + " " + database;// backup tung schems
                //arg = " -i -h " + ip + " -p " + post + " -U " + owner + " -F c -b -v -f " + s + tenfile + ".backup  " + database;
                f = new backup(file, arg, true, true);
                f.Launch();
            }
        }
        private void chuyendlbieu01_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bieu01 f = new Bieu01(s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }
        #endregion
        # region Baocao
        private void bccToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Baocao_chamcong f = new Baocao_chamcong(s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }

        private void pnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Baocao_ngayphep f = new Baocao_ngayphep(s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }
        private void bc_thchamcongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_thchamcong f = new frmbc_thchamcong(s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }        

        private void InllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmInLyLich frm = new frmInLyLich(s_makp,user_dn);
            frm.MdiParent = this;
            frm.Show();
        }

        private void InlltnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmInLyLichTrichNgang frm = new frmInLyLichTrichNgang(s_makp,user_dn);
            frm.MdiParent = this;
            frm.Show();
        }

        private void IngcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmLyLichDaoTaoGiaCanh frm = new frmLyLichDaoTaoGiaCanh(s_makp,user_dn);
            frm.ShowDialog(this);
        }
        private void dangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DS_DangVien f = new DS_DangVien(s_makp, user_dn);
            f.MdiParent = this;
            f.Show();
        }
        private void thldc_tangthemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmBCTHL_DCtangthem frm = new frmBCTHL_DCtangthem(s_makp,user_dn);
            frm.ShowDialog(this);
        }

        private void dsbcvanbcToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            frmDSBCvaNBC frm = new frmDSBCvaNBC(s_makp,user_dn);
            frm.ShowDialog(this);
        }
        private void thongkenhansuToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmThongKeNhanSu frm = new frmThongKeNhanSu(s_makp,user_dn);
            frm.ShowDialog(this);
        }
        
        private void danhsachbinhbauToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_Dsbinhbauthidua frm = new frm_Dsbinhbauthidua(s_makp,user_dn);
            frm.ShowDialog(this);
        }

        private void Dsdatldtientien_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDSLDtientien frm = new frmDSLDtientien(s_makp,user_dn);
            frm.ShowDialog(this);
        }

        private void DSDN_tangbangkhenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDSDN_Tangbangkhen frm = new frmDSDN_Tangbangkhen(s_makp,user_dn);
            frm.ShowDialog(this);
        }

        private void dstienthuongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDSLD_tientientheotienthuong frm = new frmDSLD_tientientheotienthuong(s_makp,user_dn);
            frm.ShowDialog(this);
        }
        private void danhsachcanbobenhvienToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BaocaoDSCBcomat f = new BaocaoDSCBcomat(s_makp,user_dn);
            f.ShowDialog();
        }
       
        private void toolStripMenuItem15_Click(object sender, EventArgs e)
        {
            frmBCthongkechatluong_CBCC f = new frmBCthongkechatluong_CBCC(s_makp,user_dn);
            f.ShowDialog();
        }

        private void danhSáchCánBộCôngChứcĐếnNgàyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmdanhsachCBCNV f = new frmdanhsachCBCNV(s_makp,user_dn);
            f.ShowDialog();
        }

        private void toolStripMenuItem16_Click(object sender, EventArgs e)
        {
            frmTonghopdanhgiaCBCC f = new frmTonghopdanhgiaCBCC(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Baocaotanggiamlaodong f = new Baocaotanggiamlaodong(s_makp,user_dn);
            f.ShowDialog();
        }

        private void toolStripMenuItem17_Click(object sender, EventArgs e)
        {
            BcLaodongvathunhapkhuvucnn f = new BcLaodongvathunhapkhuvucnn(s_makp,user_dn);
            f.ShowDialog();
        }

        private void toolStripMenuItem19_Click(object sender, EventArgs e)
        {
            bieu_tinhhinhCCVCtheoquy b = new bieu_tinhhinhCCVCtheoquy(s_makp,user_dn);
            b.ShowDialog();
        }

        private void thốngKêTìnhHìnhNhânSựmẫu2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmReport_bc1 f = new frmReport_bc1("ThongKeTinhHinhNhanLuc",s_makp,user_dn);
            f.ShowDialog();
        }

        private void toolStripMenuItem20_Click(object sender, EventArgs e)
        {
            frmReport_bc1 f = new frmReport_bc1("TongHopLaoDong",s_makp,user_dn);
            f.ShowDialog();
        }

        private void toolStripMenuItem21_Click(object sender, EventArgs e)
        {
            frm_danhsachlanhdao f = new frm_danhsachlanhdao(s_makp,user_dn);
            f.ShowDialog();
        }

        private void toolStripMenuItem22_Click(object sender, EventArgs e)
        {
            frmReport_bc1 f = new frmReport_bc1("DanhSachCanBoDiNuocNgoai",s_makp,user_dn);
            f.ShowDialog();
        }
        private void toolStripMenuItem23_Click(object sender, EventArgs e)
        {
            DS_DangVien f = new DS_DangVien(s_makp,user_dn);
            f.ShowDialog();
        }

        private void fileExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_boyteexel f = new frmbc_boyteexel(s_makp,user_dn);
            f.ShowDialog();
        }     

        private void thongtinnhanluc_bvToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_thongtinnhanlucbv f = new frmbc_thongtinnhanlucbv(s_makp,user_dn);
            f.ShowDialog();
        }

        private void kehoachnhanlucToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_kehoachhanluc f = new frmbc_kehoachhanluc(s_makp,user_dn);
            f.ShowDialog();
        }

        private void ldhd_ngaobcvadbToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_laodonghopdongngoai_bcdb f = new frmbc_laodonghopdongngoai_bcdb(s_makp,user_dn);
            f.ShowDialog();
        }

        private void dmtrinhdothtoolStripMenuItem13_Click(object sender, EventArgs e)
        {
            frm_dmtdth f = new frm_dmtdth();
            f.MdiParent = this;
            f.Show();
        }

        private void xemtthsnhanvienToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_cacloaiheso f = new frmbc_cacloaiheso(s_makp,user_dn);
            f.ShowDialog();
        }
        private void dungthoihan_quyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDanhSachCBCNVDeNghiNangLuong_quy frm = new frmDanhSachCBCNVDeNghiNangLuong_quy(m_admin,s_makp,user_dn);
            frm.MdiParent = this;
            frm.Show();
        }

        private void truocthoihan_quyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_DNNL_truocthoihan_theoquy_lb f = new frm_DNNL_truocthoihan_theoquy_lb(m_admin,s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }
        private void bclaodongtheobophanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_ldtheotungbophan f = new frmbc_ldtheotungbophan(s_makp,user_dn);
            f.ShowDialog();

        }

        private void thongkenhanlucyteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_boyteexel_lb f = new frmbc_boyteexel_lb();
            f.ShowDialog();
        }

        private void ldhd_ngoaibc_lbToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_laodonghopdongngoai_bcdb_lb f = new frmbc_laodonghopdongngoai_bcdb_lb();
            f.ShowDialog();
        }

        private void biendongnhanluc_lbToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_biendong_dknl f = new frmbc_biendong_dknl(s_makp,user_dn);
            f.ShowDialog();
        }

        private void thongke_ldtienluongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmThongKeLDTienLuong frm = new frmThongKeLDTienLuong(s_makp,user_dn);
            frm.ShowDialog();

        }
        private void dienbienluongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_dienbienhesoluongnv f = new frmbc_dienbienhesoluongnv(s_makp,user_dn);
            f.ShowDialog();
        }
        private void bcld_hopdongngoaibiencheToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_laodonghopdongngoai_bcdb f = new frmbc_laodonghopdongngoai_bcdb(s_makp,user_dn);
            f.ShowDialog();
        }
        private void bcc_thuongtrucToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_chamcongthuongtruc f = new frmbc_chamcongthuongtruc(s_makp,user_dn);
            f.ShowDialog();
        }
        private void bc_clcbcctheolinhvuctoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmBCCLCBCC_chiatheolinhvuc f = new frmBCCLCBCC_chiatheolinhvuc(s_makp,user_dn);
            f.ShowDialog();
        }

        private void BC_CLCBCC_theodonviToolStripMenuItem_Click(object sender, EventArgs e)
        {             
            frmbc_tonghopchatluongvienchuc f = new frmbc_tonghopchatluongvienchuc(s_makp,user_dn);
            f.ShowDialog();         
        }

        private void bc_ccngoaigiotoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_chamcong_ngoaigio frm = new frmbc_chamcong_ngoaigio(s_makp,user_dn);
            frm.ShowDialog(this);
        }
        private void bctructc_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_chamcongtructc f = new frmbc_chamcongtructc(s_makp,user_dn);
            f.ShowDialog();
        }
        private void tonghopnhanluc_bvtp_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_tonghopnhanluc_tq f = new frm_tonghopnhanluc_tq(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bv_tuyenquanToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void baocaochatluongcbvcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_chatluongcbvc_tq f = new frmbc_chatluongcbvc_tq(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcchatluongcbvcmau2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_chatluongcbvc_tq_m1 f = new frmbc_chatluongcbvc_tq_m1(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bccocaucbvcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_cocaucbvc f = new frmbc_cocaucbvc(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcthongkecocaucbvcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_thongkecocaucbvc f = new frmbc_thongkecocaucbvc(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bccocautheochuyenmonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_cocaucbvctheochuyenmon f = new frmbc_cocaucbvctheochuyenmon(s_makp,user_dn);
            f.ShowDialog();
        }

        
        private void dsnv_vangmattrongngay_Click(object sender, EventArgs e)
        {
            frm_dsnv_vangmat f = new frm_dsnv_vangmat(s_makp,user_dn);
            f.ShowDialog();
        }

        private void dsbinhbau_dvtoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dsbinhbaudonvi f = new frm_dsbinhbaudonvi(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcchamcong_nghitoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_chamcongnghi f = new frmbc_chamcongnghi(s_makp,user_dn);
            f.ShowDialog();
        }

        private void dsdv_bvtuyenquangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //frm_dsdangvien_bvtq f = new frm_dsdangvien_bvtq();
            //f.ShowDialog();
        }

       

        private void quatrinhdaotaoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmQuaTrinhCongTac frm = new frmQuaTrinhCongTac(s_makp,user_dn);
            frm.ShowDialog(this);
        }

        private void ds_danhsachnhanvienToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDanhSachNV frm = new frmDanhSachNV(this,s_makp,user_dn);
            frm.MdiParent = this;
            frm.Show();
        }

        private void ds_dksudungldToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDangKyLaoDong frm = new frmDangKyLaoDong(s_makp,user_dn);
            frm.ShowDialog();
        }

        private void ds_dnkyhdldToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDSDeNghiKyHDLD frm = new frmDSDeNghiKyHDLD(s_makp,user_dn);
            frm.ShowDialog();
        }

        private void ds_nvmoituyendungToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_dsnvmoituyentrongnam f = new frmbc_dsnvmoituyentrongnam(s_makp,user_dn);
            f.ShowDialog();
        }

        private void ds_nvmoinghiviecToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_dsnvnghiviec f = new frmbc_dsnvnghiviec(s_makp,user_dn);
            f.ShowDialog();
        }

        private void ds_concbcnvToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDanhSachConCB frm = new frmDanhSachConCB(s_makp,user_dn);
            frm.ShowDialog(this);
        }

        private void ds_dnxettuyenvienchuctoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDSDDNXTvienchuc frm = new frmDSDDNXTvienchuc(s_makp,user_dn);
            frm.ShowDialog(this);
        }

        private void ds_nvmoituyendungBVTQToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_dsnvnghiviec_tq f = new frmbc_dsnvnghiviec_tq();
            f.ShowDialog();
        }
        private void dsnv_hopdongngoai_bcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_dsnvhopdongngoaibc f = new frmbc_dsnvhopdongngoaibc(s_makp,user_dn);
            f.ShowDialog();
        }
        private void dsnv_dangdihocToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDSCB_Dangdihoc f = new frmDSCB_Dangdihoc(s_makp,user_dn);
            f.ShowDialog();
        }
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            frm_dsnvdukiennghihuu f = new frm_dsnvdukiennghihuu(s_makp,user_dn);
            f.ShowDialog();
        }
        private void dsdn_nangvk_theodotToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_danhsachvk f = new frm_danhsachvk(m_admin,s_makp,user_dn);
            f.MdiParent = this;
            f.Show();
        }       

        private void bcnl_dungthoihan_quyToolStripMenuItem_Click(object sender, EventArgs e)
        {
           
            frm_bcnangbacluongdungthoihan f = new frm_bcnangbacluongdungthoihan(s_makp,user_dn);
            f.ShowDialog();
        }        
        private void bcnl_truocthoihan_quyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_kqnangbacluongtruocthoihan_quy f = new frmbc_kqnangbacluongtruocthoihan_quy(s_makp,user_dn);
            f.ShowDialog();
        }    

        private void bcnvk_quyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_kqnangvuotkhung_quy f = new frmbc_kqnangvuotkhung_quy(s_makp,user_dn);
            f.ShowDialog();
        }      

        private void tkld_bangkedsccvatienluongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmBCdslgCBCC f = new frmBCdslgCBCC(s_makp,user_dn);
            f.ShowDialog(this);
        }

        private void bk_dsccvatienluong_chitietToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_bangkedsccvatinluong f = new frm_bangkedsccvatinluong(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bc_khenthuongvakyluatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_khenthuongkyluat f = new frm_khenthuongkyluat(s_makp,user_dn);
            f.ShowDialog();
        }
        
        private void bctk_tinhhinhnhansu_mau2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmReport_bc1 f = new frmReport_bc1("BieuMauThongKeNhanSu",s_makp,user_dn);
            f.ShowDialog();
        }
        private void dscbcc_giuchucvulanhdaoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDStrinhdolanhdaovacbcc f = new frmDStrinhdolanhdaovacbcc(s_makp,user_dn);
            f.ShowDialog();
        }
        private void ds_trichngang_cbccToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDStrichngangcbcc f = new frmDStrichngangcbcc(s_makp,user_dn);
            f.ShowDialog();
        }
        private void dsngaysinhnvToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_ngaysinhnhanvien f = new frmbc_ngaysinhnhanvien(s_makp, user_dn);
            f.ShowDialog();
        }
        private void bc_biendongvaduliennlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_biendong_dknl f = new frmbc_biendong_dknl(s_makp,user_dn);
            f.ShowDialog();
        }
        private void bctk_laodongtuyentinhToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_boyte_thongke_laodong_tuyentinh f = new frmbc_boyte_thongke_laodong_tuyentinh(s_makp,user_dn);
            f.ShowDialog();
        }        

        private void bctk_ldtuyenhuyentoolStripMenuItem1_Click(object sender, EventArgs e)
        {
            frmbc_boyteexel_lb f = new frmbc_boyteexel_lb();
            f.ShowDialog();
        }        

        private void dstn_CBYTBVTTToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dstrichngangcbyt_bvtt f = new frm_dstrichngangcbyt_bvtt(s_makp,user_dn);
            f.ShowDialog();
        }

        private void dstn_CBYTBVXAToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dstrichngangcbyt_bvxa f = new frm_dstrichngangcbyt_bvxa(s_makp,user_dn);
            f.ShowDialog();
        }

        private void dstn_cbphongyteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dstrichngangcbyt_bvthon f = new frm_dstrichngangcbyt_bvthon(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bccl_vienchuctoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_chatluongvienchuc f = new frmbc_chatluongvienchuc(s_makp,user_dn);
            f.ShowDialog();
        }
        # endregion       

        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void ngangToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void thbc_chamcongvathuongtrucToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_bangchamcong f = new frm_bangchamcong(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bccc_ngoaigiotheonhanvienToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_bclamthemgio f = new frm_bclamthemgio(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bc_ccng_theongayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_ccngtheongay f = new frmbc_ccngtheongay(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcth_chamcongthangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_tonghopchamcongthang f = new frmbc_tonghopchamcongthang(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcccvt_nvchamcongtrongngayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dsnvchamcongtrongngay f = new frm_dsnvchamcongtrongngay(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcccvt_nvchamcongtrongthangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_chamcongthang f = new frm_chamcongthang(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcccvt_nvvangmattrongngayToolStripMenuIte_Click(object sender, EventArgs e)
        {
            frm_vangmattrongngay f = new frm_vangmattrongngay(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcccvt_nvvangmattrongthangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_vangmattrongthang f = new frm_vangmattrongthang(s_makp,user_dn);
            f.ShowDialog();
        }
        private void bcccvt_bhtonghoptheonhanvienToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_tonghopchamcong f = new frmbc_tonghopchamcong(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcccvt_songaydilamToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_songaydilam f = new frm_songaydilam(s_makp,user_dn);
            f.ShowDialog();
        }       

        private void bc_chitietccngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_chitietccng_theothang f = new frmbc_chitietccng_theothang(s_makp,user_dn);
            f.ShowDialog();
        }

        private void dmchiboToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dmchibo f = new frm_dmchibo();
            f.ShowDialog();
        }

        private void dmcvdangToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dmchucvudang f = new frm_dmchucvudang();
            f.ShowDialog();
        }

        private void tkld_vathunhaptoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_baocaolaodong_thunhap_coquannhanuoc f = new frm_baocaolaodong_thunhap_coquannhanuoc(s_makp,user_dn);
            f.ShowDialog();
        }

        private void tknv_theonhomngachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_dsnvtheonhomngach f = new frmbc_dsnvtheonhomngach(s_makp,user_dn);
            f.ShowDialog();
        }
        
        private void capnhatnv_vangmattoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_nvvangmat f = new frm_nvvangmat(s_makp, m_admin);
            f.ShowDialog();
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            frm_bieutinhhinhcanbo_bvdktinh f = new frm_bieutinhhinhcanbo_bvdktinh(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bcnangluongthuongxuyentheonhomngachToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void thcocaucanboToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_tonghopcocaucanbo_hg f = new frmbc_tonghopcocaucanbo_hg(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bckqnangluong_theonhomngachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_bcnltxtheonhomngach f = new frm_bcnltxtheonhomngach(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bckq_nangluongtth_theonhomngachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_nlxs_theonhomngach f = new frmbc_nlxs_theonhomngach(s_makp,user_dn);
            f.ShowDialog();
        }

        private void bckq_nangvuotkhung_theohdToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_dsvuotkhungtheohopdong f = new frmbc_dsvuotkhungtheohopdong(s_makp,user_dn);
            f.ShowDialog();
        }

        private void quyetdinhnangluongtoolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_quyetdinh_nangbac_luong f = new frm_quyetdinh_nangbac_luong(s_makp,user_dn);
            f.ShowDialog();
        }

        private void dsdenghinangngachtoolStripMenuItem2_Click(object sender, EventArgs e)
        {
            frmbc_dsdenghinangngach f = new frmbc_dsdenghinangngach(m_admin,s_makp,user_dn);
            f.ShowDialog();
        }
        private void taodlchamcong_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmThangnam f = new frmThangnam(user_dn,m_admin);
            f.ShowDialog(this);
        }

        private void taodsdk_ngoaigioToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_taodlieu_ng f = new frm_taodlieu_ng();
            f.ShowDialog();
            if (f.closes)
            {
                frm_dsnvng f1 = new frm_dsnvng(f.mmyy, s_makp, m_admin);
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void taodsdk_thuongquyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_taodlieu_ng f = new frm_taodlieu_ng();
            f.ShowDialog();
            if (f.closes)
            {
                frm_dsnv_thuongquy f1 = new frm_dsnv_thuongquy(f.mmyy, s_makp, m_admin);
                f1.MdiParent = this;
                f1.Show();
            }
        }

        private void dmlydonghi_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmNghiphep f = new frmNghiphep();
            f.ShowDialog(this);
        }

        private void dmcalamviec_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmkhaibaocalamviec f = new frmkhaibaocalamviec();
            f.ShowDialog();
        }

        private void dmngaynghibule_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_ngaynghile f = new frm_ngaynghile();
            f.ShowDialog();
        }

        private void dmqdthoigiantre_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dmquydinhchamcong f = new frm_dmquydinhchamcong();
            f.ShowDialog();
        }

        private void mapmanv_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmMap_danhsachnhanvien f = new frmMap_danhsachnhanvien();
            f.ShowDialog();
        }

        private void mapmakp_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_mapkpMedisoft f = new frm_mapkpMedisoft();
            f.ShowDialog();
        }

        private void mapmakpbieu01_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmCapnhat f = new FrmCapnhat();
            f.ShowDialog();
        }

        private void dsnvthamgiabh_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_dsnvthamgiabaohiem f = new frmbc_dsnvthamgiabaohiem(s_makp,user_dn);
            f.ShowDialog();
        }

        private void dsnv_nghithaisanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_dsnvnghithaisan f = new frm_dsnvnghithaisan();
            f.ShowDialog();
        }

        private void thngaycong_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frm_thngaycong f = new frm_thngaycong(s_makp,user_dn,m_admin);
            f.ShowDialog();
        }

        private void bcct_tienluongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_bangluongchitiet f = new frmbc_bangluongchitiet(user_dn);
            f.ShowDialog();
        }

        private void docToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void bangtt_pcthuongtrucToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_Pcap_thuongtruc f = new frmbc_Pcap_thuongtruc(user_dn);
            f.ShowDialog();
        }

        private void bangtt_pcngoaigioToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_ngoaigio f = new frmbc_ngoaigio(user_dn);
            f.ShowDialog();
        }

        private void bangtt_tructangcuongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_pctructangcuong f = new frmbc_pctructangcuong(user_dn);
            f.ShowDialog();
        }

        private void bangtt_pcthuongquyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_thuongquy f = new frmbc_thuongquy(user_dn);
            f.ShowDialog();
        }

        private void bangtt_truylanhnangbacluongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_truylanhbacluong f = new frmbc_truylanhbacluong(user_dn);
            f.ShowDialog();
        }

        private void bangtt_truylnhnangvuotkhungToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_truylanhthamnienvuotkhung f = new frmbc_truylanhthamnienvuotkhung(user_dn);
            f.ShowDialog();
        }

        private void bangtt_truylanhthaisanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_huongchedonghi f = new frmbc_huongchedonghi(0,user_dn);
            f.ShowDialog();
        }

        private void bangtt_pcboiduonghvToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_boiduonghienvat f = new frmbc_boiduonghienvat(user_dn);
            f.ShowDialog();
        }

        private void bangtt_pcptttToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbc_Pcap_pttt f = new frmbc_Pcap_pttt(user_dn);
            f.ShowDialog();
        }
    }
}